Skip to content

Commit 189fa97

Browse files
authored
fix: Fix function in resource fetcher that produced the same name for different requires in development mode (#396)
## Description When loading two models using require the 2nd would overwrite the 1st one, cause this function produced the same name for them. It worked for remote URLs that were different in path part (the one divided by slashes), but locally loaded files only differ by GET params, that were cut off by split('?')[0]. This fixes it. It might be considered breaking change in a sense it may change names of models in the current app, so models will redownload ### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update (improves or adds clarity to existing documentation) ### Tested on - [ ] iOS - [x] Android ### Checklist - [x] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [x] My changes generate no new warnings
1 parent 604b90f commit 189fa97

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/react-native-executorch/src/utils/ResourceFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class ResourceFetcher {
148148

149149
private static getFilenameFromUri(uri: string) {
150150
let cleanUri = uri.replace(/^https?:\/\//, '');
151-
cleanUri = cleanUri.split('?')?.[0]?.split('#')?.[0] ?? cleanUri;
151+
cleanUri = cleanUri.split('#')?.[0] ?? cleanUri;
152152
return cleanUri.replace(/[^a-zA-Z0-9._-]/g, '_');
153153
}
154154

0 commit comments

Comments
 (0)