Skip to content

Commit

Permalink
fix: query object been encoded again on iOS side (#739)
Browse files Browse the repository at this point in the history
* fix: query object been encoded again on iOS side

* chore: add changeset

* fix: use a cleaner way to prevent double encoding, and format codes.

---------

Co-authored-by: Rain_Jiang <[email protected]>
  • Loading branch information
ra1nj and rainjiang authored Sep 12, 2024
1 parent 014a981 commit 300524b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-ants-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@callstack/repack': patch
---

Fix url encoded twice issue on iOS side
8 changes: 6 additions & 2 deletions packages/repack/ios/ScriptConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ + (ScriptConfig *)fromConfig:(JS::NativeScriptManager::NormalizedScriptLocator &
{
NSDictionary *_Nullable headers = (NSDictionary *)config.headers();
NSURLComponents *urlComponents = [NSURLComponents componentsWithString:config.url()];
urlComponents.query = config.query();
if (config.query() != nil) {
urlComponents.percentEncodedQuery = config.query();
}
NSURL *url = urlComponents.URL;

return [[ScriptConfig alloc] initWithScript:scriptId
Expand All @@ -40,7 +42,9 @@ + (ScriptConfig *)fromConfig:(JS::NativeScriptManager::NormalizedScriptLocator &
+ (ScriptConfig *)fromConfig:(NSDictionary *)config withScriptId:(nonnull NSString *)scriptId
{
NSURLComponents *urlComponents = [NSURLComponents componentsWithString:config[@"url"]];
urlComponents.query = config[@"query"];
if (config[@"query"] != nil) {
urlComponents.percentEncodedQuery = config[@"query"];
}
NSURL *url = urlComponents.URL;

return [[ScriptConfig alloc] initWithScript:scriptId
Expand Down

0 comments on commit 300524b

Please sign in to comment.