Git Product home page Git Product logo

Comments (8)

lifaon74 avatar lifaon74 commented on August 26, 2024

The polyfill should not be used to check url errors. It's light and because of it, it can't check every patterns. For a full implementation but bigger: https://github.com/lifaon74/whatwg-url

from url-polyfill.

myadzel avatar myadzel commented on August 26, 2024

The polyfill should not be used to check url errors

It is expected that the URL polyfill will behave in the same way as the native URL.

from url-polyfill.

lifaon74 avatar lifaon74 commented on August 26, 2024

Not possible: the full implementation is probably near the megabyte ! This is because of the support of punycodes, parser, unicode chars, etc... such a big polyfill is not recommended for user with limited bandwidth. Instead this polyfill covers 95%~99% of the specs which doesn't require long code.

As long as the url is correct, the parser will work as expected BUT in case of special url (unicode chars, malformed, etc..) the polyfill may be incorrect: Because of this, the polyfill SHOULD NOT be used to check if an url is fully correct or not (because there will always be a case where an url (provided by the client) is not compliant. So its unsafe !). For this, use on backend the whatwg-url instead.

from url-polyfill.

myadzel avatar myadzel commented on August 26, 2024

Thanks.

from url-polyfill.

zloirock avatar zloirock commented on August 26, 2024

@lifaon74 the main problem only in support custom encoding in search query params and malformed unicode character. core-js URL implementation is almost full and takes just some kilobytes.

from url-polyfill.

lifaon74 avatar lifaon74 commented on August 26, 2024

The core-js url implementation is in the range of 50KB (non gziped) but requires a lot of dependencies to work properly which increases the bundle size. This polyfill (url-polyfill) is arround 13KB (non gziped) and requires no dependencies at all. Moreover, this repo was done before any implementation of URL by core-js.

Of course, now, it may be more interesting to use core-js... It only depends of your needs.

from url-polyfill.

zloirock avatar zloirock commented on August 26, 2024

The core-js url implementation is in the range of 50KB (non gziped)

Minified, without gzip and the rest parts of core-js, it takes ~17kb.

You are right, my comment was related just to "not possible" and the reasons. But sure, this more simple polyfill make sense for some cases.

from url-polyfill.

zloirock avatar zloirock commented on August 26, 2024

More other, your issue was one the reasons for adding URL polyfill to core-js -)

from url-polyfill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.