Skip to content

punycode: remove module detection - #5868

Closed
benjamingr wants to merge 1 commit into
nodejs:masterfrom
benjamingr:punycode-remove-module-detection
Closed

benjamingr wants to merge 1 commit into
nodejs:masterfrom
benjamingr:punycode-remove-module-detection

Conversation

@benjamingr

Copy link
Copy Markdown
Member

Please provide affected core subsystem(s) (like buffer, cluster, crypto, etc)

punycode, url

Description of change

The current punycode code is copy-pasted from a package that is meant to be used both in browsers and node. This commit removes the module detection from punycode and assumes node.

If this gets received well, I intend to do more basic work to make the module more maintainable.

As discussed in #5865

Labeled as URL since it uses it internally.

The current punycode code is copy-pasted from a package that is meant
to be used both in browsers and node. This commit removes the module
detection from punycode and assumes node.

If this gets received well, I intend to do more basic work to make
the module more maintainable.

Refs: nodejs#5865

PR-URL:
Reviewed-By:
Reviewed-By:
@benjamingr benjamingr added the url Issues and PRs related to the legacy built-in url module. label Mar 23, 2016
@benjamingr

Copy link
Copy Markdown
Member Author

Note: the diff looks huge, so I'll summarize it - the code was wrapped in an IIFE and finished with module detection. Now it's no longer wrapped in an extra (function(global) { ... })(this) and I removed the code detecting the module system at the bottom.

Future changes I intend to do if this gets received well:

  • Convert the file to standard node spacing (two spaces).
  • Convert reimplemented methods to standard methods.
  • Remove IE8 compatibility fixes.
  • Convert vars to const.
  • Remove irrelevant browser specific bits.

After that's done, I'll look into performance, the current module is very well documented and it's not bad code at all - but it's not very optimized in terms of performance for v8.

@mscdex

mscdex commented Mar 23, 2016

Copy link
Copy Markdown
Contributor

I think the reason it was copied verbatim is so that there's no maintenance burden when new versions are merged.

@bnoordhuis

Copy link
Copy Markdown
Member

What @mscdex said. This PR makes maintenance more difficult, not easier.

@benjamingr

Copy link
Copy Markdown
Member Author

@mscdex the last time a version has been merged has been in 2014 from what I can tell. Is it still actively maintained? ping @mathiasbynens

Maybe we should update to 1.4 then.

@benjamingr

Copy link
Copy Markdown
Member Author

@bnoordhuis wouldn't it be better to use something like https://github.com/bnoordhuis/punycode in terms of performance? The JS implementation uses things that are not very performance friendly from what I saw.

@bnoordhuis

Copy link
Copy Markdown
Member

We moved to punycode.js years ago because my library isn't 100% spec compliant. :-)

@benjamingr

Copy link
Copy Markdown
Member Author

Oh, I understand, I'll close this then and open a new PR based on the spec compliant library. Thanks.

@benjamingr benjamingr closed this Mar 23, 2016
@benjamingr

Copy link
Copy Markdown
Member Author

Looks like it hasn't really been updated (looking at the code) between 1.3.2 and 1.4.1.

@MylesBorins

Copy link
Copy Markdown
Contributor

I know that this is closed... but for reference

#4969

Similar thread, project decided not to remove code

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

Labels

url Issues and PRs related to the legacy built-in url module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants