Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export class API {
* @param path the vault relative path of the file to import
*/
public async importJs(path: string): Promise<any> {
const fullPath = this.app.vault.adapter.getResourcePath(path);
let fullPath = this.app.vault.adapter.getResourcePath(path);
if (!fullPath.includes('?')) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the path on mobile includes a ? somewhere along the way?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this/is/a?path/foo.js

Copy link
Contributor Author

@Krakor92 Krakor92 Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it have one? Isn't ? an illegal character to have in a path or in a filename? If you're talking about a mobile path that already contains query parameters then It shouldn't be the case since on mobile, getResourcePath doesn't append anything at the end of the full path.

Edit: If you prefer I can construct an URL object with the full path and check whether or not it has a searchParams.size === 0

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const scriptFile = this.app.metadataCache.getFirstLinkpathDest(path, "")
if (scriptFile) {
fullPath += '?' + scriptFile.stat.mtime
}
}
return import(fullPath);
}

Expand Down