Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behaviour with urls after updating to Xcode 15 #320

Open
saransh-malik opened this issue Sep 22, 2023 · 6 comments
Open

Weird behaviour with urls after updating to Xcode 15 #320

saransh-malik opened this issue Sep 22, 2023 · 6 comments

Comments

@saransh-malik
Copy link

Facing a very strange issue after upgrading to Xcode 15. All the urls that have query params in the url, have the percentage symbol encoded twice,
so with Xcode 14.3, this was how the url looked
https://test.com/organizations/1/pins?$filters=%7B%22mapped%22:true,%22entities%22:%7B%22accounts%22:%7B%22includeGroups%22:true%7D,%22contacts%22:%7B%22includeGroups%22:true%7D%7D,%22includeCustomFields%22:true,%22pinLegends%22:%7B%22accounts%22:%7B%22shape%22:645981,%22color%22:645680%7D,%22contacts%22:%7B%22shape%22:645696,%22color%22:645732%7D%7D%7D&$order=%7B%22point%22:%5B77.191642,28.60893931596358%5D,%22unit%22:%22miles%22%7D&$limit=100

and then with Xcode 15, same url with no changes gets converted as this
https://test.com/organizations/1/pins?$filters=%257B%2522mapped%2522:true,%2522entities%2522:%257B%2522accounts%2522:%257B%2522includeGroups%2522:true%257D,%2522contacts%2522:%257B%2522includeGroups%2522:true%257D%257D,%2522includeCustomFields%2522:true,%2522pinLegends%2522:%257B%2522accounts%2522:%257B%2522shape%2522:501951,%2522color%2522:593346%257D,%2522contacts%2522:%257B%2522shape%2522:517158,%2522color%2522:608557%257D%257D%257D&$order=%257B%2522point%2522:%5B-122.406417,37.785834%5D,%2522unit%2522:%2522miles%2522%257D&$limit=100

Notice how every percentage symbol has been encoded to %25 making the url invalid.

I did no changes and as soon as we revert back to Xcode 14.3 everything works fine again. Any idea what is causing this and how do we fix this?

Not sure, if this is linked to library but since we use this to send all requests was wondering if encoding happens at library level or native level.

@jeveloper
Copy link

I found the same issue

@zenjedi
Copy link

zenjedi commented Mar 22, 2024

@saransh-malik @jeveloper were you able to find a way out?

@saransh-malik
Copy link
Author

@saransh-malik @jeveloper were you able to find a way out?

Yes, you need to use paramSearlizer prop and format the urls on your own that gets it working.

@zenjedi
Copy link

zenjedi commented Mar 28, 2024

Can you share a code snippet please?

@saransh-malik
Copy link
Author

saransh-malik commented Apr 4, 2024

Can you share a code snippet please?

Yup this is how I am doing it currently

paramsSerializer: params => {
       let result = ''
       Object.keys(params ?? {}).forEach(key => {
         if (
           typeof params?.[key] === 'object' &&
           params?.[key] &&
           Object.keys(params?.[key] ?? {})
         ) {
           result += `${key}=${encodeURIComponent(
             JSON.stringify(params[key])
           )}&`
         } else if (params[key] !== undefined) {
           result += `${key}=${encodeURIComponent(params[key])}&`
         }
       })
       return result?.substring(0, result?.length - 1)
     },

@zenjedi
Copy link

zenjedi commented Apr 7, 2024

Thanks @saransh-malik . I can confirm your serializer code works. Thanks and cheers! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants