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

URL and URLSearchParams is not working #38656

Open
natanfeitosa opened this issue Jul 27, 2023 · 4 comments
Open

URL and URLSearchParams is not working #38656

natanfeitosa opened this issue Jul 27, 2023 · 4 comments
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: Triage 🔍

Comments

@natanfeitosa
Copy link

Description

I was working with React Native and I needed to parse a URL to get a parameter, for that I used the URL class and got the serialized searchParams, but in every attempt it gave all kinds of errors.

const url = new URL('https://somesite.com/?search=param')

console.log(url.searchParams.get('search')) //  Throw 'URLSearchParams.get is not implemented'
console.log(url.searchParams.toString()) // ''

React Native Version

0.72.3

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: Linux 5.4 Linux Mint 20 (Ulyana)
CPU: (2) x64 Intel(R) Core(TM)2 CPU 6400 @ 2.13GHz
Memory: 304.14 MB / 1.92 GB
Shell:
version: "5.8"
path: /usr/bin/zsh
Binaries:
Node:
version: 18.12.1
path: /usr/local/bin/node
Yarn:
version: 1.22.19
path: ~/.yarn/bin/yarn
npm:
version: 8.19.2
path: /usr/local/bin/npm
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java:
version: 11.0.19
path: /usr/bin/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.3
wanted: 0.72.3
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

Steps to reproduce

1 - Clone the repo
2 - Install its dependecies
3 - Run the project using your favorite platform
4 - Try to input some url

Snack, screenshot, or link to a repository

https://github.com/natanfeitosa/RNUrlBugReport

@cortinico cortinico added the Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. label Jul 31, 2023
@hbriese
Copy link

hbriese commented Aug 1, 2023

Hermes doesn't support URL. You can polyfill it using core-js

Import this early in your app (index.ts or App.tsx)

import 'core-js/actual/url';
import 'core-js/actual/url-search-params';

@natanfeitosa
Copy link
Author

Thanks. I already sent a PR to fix #38675

@ndronov
Copy link

ndronov commented Oct 5, 2023

Hi! is there any information about status of issue?
@cortinico @natanfeitosa

@natanfeitosa
Copy link
Author

@ndronov it was fixed in this pr, waiting for merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: Triage 🔍
Projects
None yet
Development

No branches or pull requests

4 participants