[js/web] allow relative path matching (#21657)

### Description
<!-- Describe your changes. -->

This change allows to match external data path like `a.data` to
`./a.data`.


<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
Yulong Wang 2024-08-09 03:13:40 -07:00 committed by GitHub
parent ae2b4d31ea
commit f4ec85259a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,9 @@
* @param {Uint8Array} externalDataFilesData
*/
Module['mountExternalData'] = (externalDataFilePath, externalDataFileData) => {
if (externalDataFilePath.startsWith('./')) {
externalDataFilePath = externalDataFilePath.substring(2);
}
const files = Module.MountedFiles || (Module.MountedFiles = new Map());
files.set(externalDataFilePath, externalDataFileData);
};