Skip to content

Output of URL.toString doesn't match Node/Chromium #50747

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

Open
Rexogamer opened this issue Apr 16, 2025 · 4 comments
Open

Output of URL.toString doesn't match Node/Chromium #50747

Rexogamer opened this issue Apr 16, 2025 · 4 comments

Comments

@Rexogamer
Copy link
Contributor

Rexogamer commented Apr 16, 2025

Description

(apologies if this is the wrong repo - is this a Hermes issue?)

the output of new URL().to string() doesn't seem to match Node or Chromium, which leads me to believe the bug is with React Native or whoever is implementing URL.

this bug has caused issues for me, as (say) https://foo.net?bar=baz/ is different from https://foo.net/?bar=baz (the param is baz/, when it should be baz).

Node:

Welcome to Node.js v20.18.2.
Type ".help" for more information.
> const url = 'https://github.com'
undefined
> new URL(url).toString()
'https://github.com/'
> const url2 = 'https://github.com?foo=bar'
undefined
> new URL(url2).toString()
'https://github.com/?foo=bar'
> 

versus the same functions run with RN:

 (NOBRIDGE) LOG  https://github.com/
 (NOBRIDGE) LOG  https://github.com?foo=bar/

Steps to reproduce

  1. Run the reproducer linked below
  2. Look at the sections with URLs
  3. Notice the misplaced slash at the end of the second example

React Native Version

0.79.1

Affected Platforms

Runtime - Android, Build - Linux

Output of npx @react-native-community/cli info

System:
  OS: Linux 6.11 Ubuntu 24.10 24.10 (Oracular Oriole)
  CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
  Memory: 1.55 GB / 7.03 GB
  Shell:
    version: 5.2.32
    path: /bin/bash
Binaries:
  Node:
    version: 20.18.2
    path: ~/.nvm/versions/node/v20.18.2/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.18.2/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.18.2/bin/npm
  Watchman:
    version: 0.250301-built-on-0319.0-rexo
    path: /usr/local/bin/watchman
SDKs:
  Android SDK:
    API Levels:
      - "35"
    Build Tools:
      - 34.0.0
      - 35.0.0
      - 35.0.1
    System Images:
      - android-35 | Google APIs Intel x86_64 Atom
      - android-35 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.0
    wanted: 0.79.0
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

see above

Reproducer

https://github.com/Rexogamer/react-native-url-bug

Screenshots and Videos

No response

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.79.1. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@Rexogamer Rexogamer changed the title Output of URL.toString doesn't match Node/Electron Output of URL.toString doesn't match Node/Chromium Apr 16, 2025
@Rexogamer
Copy link
Contributor Author

still reproducible in v0.79.1

@cipolleschi
Copy link
Contributor

Hi @Rexogamer, thanks for the issue.
Was this issue also happening with 0.78?

This commit 51ffc5c happened 8 month ago and it is the most recent change to the URLSearchParam implementation.
We might have a bug there.

cipolleschi added a commit to cipolleschi/react-native that referenced this issue Apr 16, 2025
Summary:
We received [this issue](facebook#50747) in OSS where the URL parsing logic does not respect node/chromium specs.

This can cause issue in usercode. This change fixes it

## Changelog:
[General][Fixed] - make sure that URLs are parsed following the node specs

Differential Revision: D73101813
cipolleschi added a commit to cipolleschi/react-native that referenced this issue Apr 16, 2025
Summary:

We received [this issue](facebook#50747) in OSS where the URL parsing logic does not respect node/chromium specs.

This can cause issue in usercode. This change fixes it

## Changelog:
[General][Fixed] - make sure that URLs are parsed following the node specs

Differential Revision: D73101813
cipolleschi added a commit to cipolleschi/react-native that referenced this issue Apr 16, 2025
Summary:

We received [this issue](facebook#50747) in OSS where the URL parsing logic does not respect node/chromium specs.

This can cause issue in usercode. This change fixes it

## Changelog:
[General][Fixed] - make sure that URLs are parsed following the node specs

Differential Revision: D73101813
cipolleschi added a commit to cipolleschi/react-native that referenced this issue Apr 16, 2025
Summary:
Pull Request resolved: facebook#50757

We received [this issue](facebook#50747) in OSS where the URL parsing logic does not respect node/chromium specs.

This can cause issue in usercode. This change fixes it

## Changelog:
[General][Fixed] - make sure that URLs are parsed following the node specs

Differential Revision: D73101813
facebook-github-bot pushed a commit that referenced this issue Apr 16, 2025
Summary:
Pull Request resolved: #50757

We received [this issue](#50747) in OSS where the URL parsing logic does not respect node/chromium specs.

This can cause issue in usercode. This change fixes it

## Changelog:
[General][Fixed] - make sure that URLs are parsed following the node specs

Reviewed By: huntie

Differential Revision: D73101813

fbshipit-source-id: 36f1d23b3ad7882c16524843621d9ebbcc09b95d
uffoltzl pushed a commit to uffoltzl/react-native that referenced this issue Apr 18, 2025
Summary:
Pull Request resolved: facebook#50757

We received [this issue](facebook#50747) in OSS where the URL parsing logic does not respect node/chromium specs.

This can cause issue in usercode. This change fixes it

## Changelog:
[General][Fixed] - make sure that URLs are parsed following the node specs

Reviewed By: huntie

Differential Revision: D73101813

fbshipit-source-id: 36f1d23b3ad7882c16524843621d9ebbcc09b95d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants