Skip to content

Can I use version 7 in the browser? #140

Closed

Description

@charbugs

The readme says:

If you need to use this in the browser, use version 4: npm i normalize-url@4

I scanned the index.js of version 7 and it seems to me that there are no Node-specific APIs involved. I also did a quick check which seems to work at first glance:

<script type="module">
    import normalizeUrl from './node_modules/normalize-url/index.js'
    console.log(normalizeUrl('foo.bar'))
</script>

So is it save to use version 7 in the browser?

Activity

  1. sindresorhus commented on Jul 14, 2021

    @sindresorhus
    Owner

    It depends on which browsers you need to support. See: #105

  2. charbugs commented on Jul 14, 2021

    @charbugs
    Author

    Thanks for the pointer!

  3. loynoir commented on Aug 7, 2021

    @loynoir

    Hi, @sindresorhus
    Is js-regexp-lookbehind the only limitation prevent using v7 in browser?
    Might be better to document the reason behind

    If you need to use this in the browser, use version 4: npm i normalize-url@4

  4. added a commit that references this issue on Aug 9, 2021
  5. loynoir commented on Aug 9, 2021

    @loynoir

    For any seeing this, after I migrate test.js from ava to mocha+chai, I would say

    Q: Can I use sindresorhus/normalize-url@7.0.0 in the browser?
    A:

    1. No if your browser don't support js-regexp-lookbehind
    2. No if you use custom scheme outside of url_special_schemes, aka outside of https/http/wss/ws/ftp/file, tested with latest chrome and firefox.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions