iOS: stringByRemovingPercentEncoding breaks
See original GitHub issueIn RNSound.m
, my AVAudioPlayer
errors out because of this line of code:
fileNameUrl = [NSURL URLWithString: [fileName stringByRemovingPercentEncoding]];
if I change it to
fileNameUrl = [NSURL URLWithString: fileName];
it works fine.
However, I’m uncomfortable changing this code. Is there a reason for using stringByRemovingPercentEncoding
? I’m try to play audio from my aws s3 bucket.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Having trouble with "removingPercentEncoding" in Swift and ...
I am having difficulty getting "removingPercentEncoding" working for an NSString in Cocoa and for String in Swift. For instance I have a text...
Read more >URL Encoding issue in swift ios - Stack Overflow
Your URL is already percent-encoded. If you encode it again, the percent parts will be encoded twice, giving an invalid URL.
Read more >Deep Linking for iOS - Braze
iOS 9 introduced a breaking change affecting web URLs embedded in in-app ... an encoded link, use the NSString method stringByRemovingPercentEncoding .
Read more >[Solved]-how to add empty space in string ios - appsloveworld
See Also – stringByAddingPercentEncodingWithAllowedCharacters: – stringByReplacingPercentEscapesUsingEncoding: – stringByRemovingPercentEncoding.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree because this string replacement the module can not play from Firebase Storage Services which uses %2F in file names.
Why is this library written to explicitly remove percent encoding on network uris, when
NSData
seems to require percent encoding?Local uris also have their percent encoding removed. Though that works, it seems unnecessary, since
fileURLWithPath
adds percent encoding back on again.And why is this only in the code for ios, not android? The code for Android reformats local uris (in
sound.js
) but not network uris.A side note -
[NSData dataWithContentsOfURL:]
is deprecated because it’s synchronous, and should be replaced with the asynchronous[[[NSURLSession sharedSession] dataTaskWithURL:_ completionHandler:_] resume]
.