Skip to content

Creating an instance of URL like: new URL('http://facebook.com') throws an exception. #16434

Closed

Description

@ipeychev

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.6.0
Yarn: 0.24.6
npm: 5.3.0
Watchman: 4.7.0
Xcode: Xcode 8.3 Build version 8E162
Android Studio: 2.3 AI-162.3934792

Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: ^0.48.4 => 0.48.4
Target Platform: iOS (10.3)

Steps to Reproduce

  1. Create a ReactNative project, which uses React Native 16
  2. Try to create an instance of URL in any .js file, like this:
    const url = new URL('http://facebook.com');
  3. Run the project

Expected Behavior

The URL to be the native URL, this one. It was working fine in React 15, but in React 16 it was replaced with something internal. We use URL to parse URLs and extract information about the hostname, port, etc. so we need this behaviour back.

Actual Behavior

An exception is thrown: Creating BlobURL objects is not supported yet.

screen shot 2017-10-17 at 18 15 19

Reproducible Demo

https://snack.expo.io/SJUA5i7TZ

Activity

  1. changed the title [-]Creating an instance of URL like `new URL('http://facebook.com')` throws an exception.[/-] [+]Creating an instance of URL like: `new URL('http://facebook.com')` throws an exception.[/+] on Oct 17, 2017
  2. phillbaker commented on Nov 8, 2017

    @phillbaker

    requiring the module seemed to work for me:

    const url = require('url');
    console.log(url.parse('https://example.com'));
    
  3. mloureiro commented on Dec 20, 2017

    @mloureiro

    @phillbaker what @ipeychev meant is the URL definition: https://developer.mozilla.org/en-US/docs/Web/API/URL
    not a custom module

  4. stale commented on Feb 18, 2018

    @stale
  5. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Feb 18, 2018
  6. Panthro commented on Feb 24, 2018

    @Panthro
  7. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Feb 24, 2018
  8. ck-kc commented on Feb 25, 2018

    @ck-kc
  9. Trenrod commented on Feb 26, 2018

    @Trenrod

    Reproduced with:
    Environment:
    OS: Windows 10
    Node: 6.12.3
    Yarn: Not Found
    npm: 3.10.10
    Watchman: Not Found
    Xcode: N/A
    Android Studio: Version 3.0.0.0 AI-171.4443003

    Packages: (wanted => installed)
    react: 16.2.0 => 16.2.0
    react-native: 0.53.3 => 0.53.3

  10. lxcid commented on Mar 11, 2018

    @lxcid

    Reproduced in:

    Environment:
      OS: macOS High Sierra 10.13.2
      Node: 9.2.0
      Yarn: 1.3.2
      npm: 5.5.1
      Watchman: 4.9.0
      Xcode: Xcode 9.2 Build version 9C40b
      Android Studio: 2.3 AI-162.4069837
    
    Packages: (wanted => installed)
      react: 16.2.0 => 16.2.0
      react-native: 0.53.2 => 0.53.2
    
  11. m-vdb commented on Mar 28, 2018

    @m-vdb

    Having the issue as well, so sad :(

    Environment:
      OS: macOS Sierra 10.12.6
      Node: 6.11.2
      Yarn: Not Found
      npm: 5.3.0
      Watchman: 4.5.0
      Xcode: Xcode 9.2 Build version 9C40b
      Android Studio: 3.0 AI-171.4443003
    
    Packages: (wanted => installed)
      react: 16.2.0 => 16.2.0
      react-native: 0.52.2 => 0.52.2
    
  12. ovy9086 commented on Apr 3, 2018

    @ovy9086
  13. andrenerd commented on Apr 3, 2018

    @andrenerd
  14. benjohnson2001 commented on Apr 24, 2018

    @benjohnson2001
  15. danlee2025 commented on Apr 27, 2018

    @danlee2025
  16. 32 remaining items

  17. Asday commented on Jun 19, 2019

    @Asday

    @satya164 Could you let me know what more information I can provide you further to my last comment?

  18. BettyJJ commented on Jul 5, 2019

    @BettyJJ

    Sad, another basic feature missing.

  19. charpeni commented on Nov 25, 2019

    @charpeni
    Contributor
  20. hramos commented on Jan 30, 2020

    @hramos
    Contributor

    Closing as a workaround is provided in #16434 (comment)

  21. added a commit that references this issue on Jun 9, 2020
  22. Nantris commented on Sep 18, 2021

    @Nantris

    @hramos if a polyfill existing is reason enough to close this issue then I think the React Native team should deprecate the URL module and outsource it to the community as they have with others. This weird, multi-year, limbo state of the URL module is not good...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions