defunctzombie / node-url

node.js core url module as a module
MIT License
375 stars 96 forks source link

Sometimes punycode is failing when it's bundled with bundlers, the result is that punnycode object is empty. #31

Closed h3xxx closed 7 years ago

h3xxx commented 7 years ago

Sometimes punycode is failing when it's bundled with bundlers (browserify, webpack), the result is that punnycode object is empty. It's causing: Uncaught TypeError: punycode.toASCII is not a function in node-url.

My suggestion it to add a condition near line 295 in url.js:

if (typeof punycode.toASCII == 'function')
    this.hostname = punycode.toASCII(this.hostname);
manuelnaranjo commented 7 years ago

Seems this branch has the issue solved by just moving out of punycode:

https://github.com/adampash/node-url/commit/01ff22ebee841a0053330d45f221371b41effbbf

h3xxx commented 7 years ago

@manuelnaranjo thanks for info, I'm closing the issue.