Skip to content

Commit 0939dbe

Browse files
committed
Adding check for external protocol in uri
1 parent f81d35a commit 0939dbe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/commons/loadWeightMap.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ export function getModelUris(uri: string | undefined, defaultModelName: string)
1616
manifestUri: `/${defaultManifestFilename}`
1717
}
1818
}
19+
const protocol = uri.startsWith('http://') ? 'http://' : uri.startsWith('https://') ? 'https://' : '';
20+
uri = uri.replace(protocol, '');
1921

2022
const parts = uri.split('/').filter(s => s)
2123

2224
const manifestFile = uri.endsWith('.json')
2325
? parts[parts.length - 1]
2426
: defaultManifestFilename
2527

26-
let modelBaseUri = (uri.endsWith('.json') ? parts.slice(0, parts.length - 1) : parts).join('/')
28+
let modelBaseUri = protocol + (uri.endsWith('.json') ? parts.slice(0, parts.length - 1) : parts).join('/')
2729
modelBaseUri = uri.startsWith('/') ? `/${modelBaseUri}` : modelBaseUri
2830

2931
return {

0 commit comments

Comments
 (0)