You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using Expo and noticed that I was getting a different result when validating a URL on web, nodejs and in my react-native app with whatwg-url-without-unicode. It seems that Expo uses this library as an implementation of URL here https://github.com/expo/expo/blob/sdk-52/packages/expo/src/winter/url.ts. and while digging I realized that there seems to be an issue with the url.searchParams.has method. When trying to match with a second argument which is the value of the search param it returns true even if the value is incorrect. I made a gist here that explains the issue:
The type definition of URLSearchParams from nodejs shows that the has method has an optional second argument called value:
/** * Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument. * * If `value` is provided, returns `true` when name-value pair with * same `name` and `value` exists. * * If `value` is not provided, returns `true` if there is at least one name-value * pair whose name is `name`. */has(name: string,value?: string): boolean;
To fix the issue 2 things are needed:
Updating src/URLSearchParams-impl.js line 78 method has will guarantee a check if a value argument is passed
It seems there's a webidl file reference of UseSearchParams which is being loaded too and results in dist/URLSearchParams.js output but since this blueprint contains a URLSearchParams.has method with only the name argument it would have to be updated to receive 2 arguments. The URLSearchParams.has method ends up calling the URLSearchParams-impl.js -> has method and will only call it with one argument if The blueprint is not updated.
Hi,
I was using Expo and noticed that I was getting a different result when validating a URL on web, nodejs and in my react-native app with
whatwg-url-without-unicode
. It seems that Expo uses this library as an implementation of URL here https://github.com/expo/expo/blob/sdk-52/packages/expo/src/winter/url.ts. and while digging I realized that there seems to be an issue with theurl.searchParams.has
method. When trying to match with a second argument which is the value of the search param it returns true even if the value is incorrect. I made a gist here that explains the issue:https://gist.github.com/federico-hv/8a5459b23867635b66f97e0605e73b57
Essentially the library is matching true for a value that is not the right one ->
url.searchParams.has('fruit', 'banana')
istrue
forfruit=apple
The text was updated successfully, but these errors were encountered: