Skip to content

Commit 411a8bf

Browse files
committed
fix(ios): Entry.toURL() to produce DOM-usable uri when using scheme-hosted webview
1 parent 17155ed commit 411a8bf

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

plugin.xml

+3
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ to config.xml in order for the application to find previously stored files.
182182
<source-file src="src/ios/CDVAssetLibraryFilesystem.m" />
183183

184184
<!-- ios specific file apis -->
185+
<js-module src="www/ios/Entry.js" name="iosEntry">
186+
<merges target="Entry" />
187+
</js-module>
185188
<js-module src="www/ios/FileSystem.js" name="iosFileSystem">
186189
<merges target="FileSystem" />
187190
</js-module>

www/ios/Entry.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*
20+
*/
21+
22+
module.exports = {
23+
/**
24+
* Return a URL that can be used to identify this entry.
25+
* Use a URL that can be used to as the src attribute of a <video> or
26+
* <audio> tag. If that is not possible, construct a http(s)://(localhost) URL.
27+
*/
28+
toURL: function () {
29+
return window.location.origin.includes('file://')
30+
? this.nativeURL
31+
: window.WkWebView.convertFilePath(this.nativeURL);
32+
}
33+
};

0 commit comments

Comments
 (0)