react / react/react-native

URL and URLSearchParams is not working

Open
#38,656 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Author Provided Repro Needs: Triage :mag:
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported URL and URLSearchParams behavior in the React Native 0.72.3 reproduction repository at github.com/natanfeitosa/RNUrlBugReport. Run the example and verify both searchParams.get('search') and searchParams.toString(). Done means these calls return the expected query value and serialized parameters without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.