mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 12:02:49 +08:00
Merge pull request #265 from okode/fix_ios_path_encoding
Fix ios path encoding
This commit is contained in:
commit
d8927a5b32
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
- (void) open: (CDVInvokedUrlCommand*)command {
|
- (void) open: (CDVInvokedUrlCommand*)command {
|
||||||
|
|
||||||
NSString *path = [[command.arguments objectAtIndex:0] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];
|
NSString *path = [command.arguments objectAtIndex:0];
|
||||||
NSString *contentType = [command.arguments objectAtIndex:1];
|
NSString *contentType = [command.arguments objectAtIndex:1];
|
||||||
BOOL showPreview = YES;
|
BOOL showPreview = YES;
|
||||||
|
|
||||||
@ -53,7 +53,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
NSURL *fileURL = [NSURL URLWithString:[path stringByRemovingPercentEncoding]];
|
NSURL *fileURL = NULL;
|
||||||
|
NSString *decodedPath = [path stringByRemovingPercentEncoding];
|
||||||
|
if ([path isEqualToString:decodedPath]) {
|
||||||
|
NSLog(@"Path parameter not encoded. Building file URL encoding it...");
|
||||||
|
fileURL = [NSURL fileURLWithPath:[path stringByReplacingOccurrencesOfString:@"file://" withString:@""]];;
|
||||||
|
} else {
|
||||||
|
NSLog(@"Path parameter already encoded. Building file URL without encoding it...");
|
||||||
|
fileURL = [NSURL URLWithString:path];
|
||||||
|
}
|
||||||
|
|
||||||
localFile = fileURL.path;
|
localFile = fileURL.path;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user