Skip to content

Commit

Permalink
feat: unify all platforms toURL behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Oct 30, 2024
1 parent 6bff845 commit 88898bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
6 changes: 3 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ to config.xml in order for the application to find previously stored files.
<framework src="androidx.webkit:webkit:$ANDROIDX_WEBKIT_VERSION" />

<!-- android specific file apis -->
<js-module src="www/android/Entry.js" name="androidEntry">
<merges target="Entry" />
</js-module>
<js-module src="www/android/FileSystem.js" name="androidFileSystem">
<merges target="FileSystem" />
</js-module>
Expand Down Expand Up @@ -182,6 +179,9 @@ to config.xml in order for the application to find previously stored files.
<source-file src="src/ios/CDVAssetLibraryFilesystem.m" />

<!-- ios specific file apis -->
<js-module src="www/ios/Entry.js" name="iosEntry">
<merges target="Entry" />
</js-module>
<js-module src="www/ios/FileSystem.js" name="iosFileSystem">
<merges target="FileSystem" />
</js-module>
Expand Down
9 changes: 3 additions & 6 deletions www/Entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,9 @@ Entry.prototype.toInternalURL = function () {
* <audio> tag. If that is not possible, construct a cdvfile:// URL.
*/
Entry.prototype.toURL = function () {
if (this.nativeURL) {
return this.nativeURL;
}
// fullPath attribute may contain the full URL in the case that
// toInternalURL fails.
return this.toInternalURL() || 'file://localhost' + this.fullPath;
return window.location.origin.includes('file://')
? this.nativeURL
: this.toInternalURL();
};

/**
Expand Down
12 changes: 4 additions & 8 deletions www/android/Entry.js → www/ios/Entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@

module.exports = {
/**
* Return a URL that can be used to identify this entry.
* Use a URL that can be used to as the src attribute of a <video> or
* <audio> tag. If that is not possible, construct a http(s)://(localhost) URL.
*/
toURL: function () {
return window.location.origin.includes('file://')
? this.nativeURL
: this.toInternalURL();
* Return a URL that can be passed across the bridge to identify this entry.
*/
toInternalURL: function () {
return window.WkWebView.convertFilePath(this.nativeURL);
}
};

0 comments on commit 88898bf

Please sign in to comment.