Skip to content

Commit

Permalink
chore(connect): rename 'getAssetByUrl' to a more apt fn name 'tryLoca…
Browse files Browse the repository at this point in the history
…lAssetRequire'
  • Loading branch information
mroz22 committed Oct 7, 2024
1 parent dc01479 commit 86667cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/connect/src/utils/assetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const firmwareAssets: Record<DeviceModelInternal, NodeRequire> = {
[DeviceModelInternal.T3T1]: require('@trezor/connect-common/files/firmware/t3t1/releases.json'),
};

export const getAssetByUrl = (url: string) => {
export const tryLocalAssetRequire = (url: string) => {
const fileUrl = url.split('?')[0];

switch (fileUrl) {
Expand Down
4 changes: 2 additions & 2 deletions packages/connect/src/utils/assets.native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { getAssetByUrl } from './assetUtils';
import { tryLocalAssetRequire } from './assetUtils';

export const httpRequest = (url: string, _type: string): any => getAssetByUrl(url);
export const httpRequest = (url: string, _type: string): any => tryLocalAssetRequire(url);
4 changes: 2 additions & 2 deletions packages/connect/src/utils/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fetch from 'cross-fetch';
import { promises as fs } from 'fs';
import { httpRequest as browserHttpRequest } from './assets-browser';
import { getAssetByUrl } from './assetUtils';
import { tryLocalAssetRequire } from './assetUtils';

if (global && typeof global.fetch !== 'function') {
global.fetch = fetch;
Expand Down Expand Up @@ -36,7 +36,7 @@ export function httpRequest(
options?: RequestInit,
skipLocalForceDownload?: boolean,
) {
const asset = skipLocalForceDownload ? null : getAssetByUrl(url);
const asset = skipLocalForceDownload ? null : tryLocalAssetRequire(url);

if (!asset) {
return /^https?/.test(url) ? browserHttpRequest(url, type, options) : fs.readFile(url);
Expand Down

0 comments on commit 86667cc

Please sign in to comment.