Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version confusion #127

Closed
depoulo opened this issue Jan 25, 2023 · 1 comment
Closed

Version confusion #127

depoulo opened this issue Jan 25, 2023 · 1 comment

Comments

@depoulo
Copy link

depoulo commented Jan 25, 2023

I just upgraded the punycode package from 2.1.0 to 2.3.0. Since I could not find a changelog or even a Git tag here, I backuped the 2.1.0 version from my node_modules folder and compared it to the version after the upgrade. They matched (empty diff)!

Then I found #122 and switched my installation to punycode.js. Now I'm seeing a difference (attached below), and importing punycode.js is obviously better than importing punycode/. But: node -pe "require('punycode.js').version" still outputs 2.1.0, taken from the source code:

punycode.js/punycode.js

Lines 418 to 425 in 36db01b

/** Define the public API */
const punycode = {
/**
* A string representing the current Punycode.js version number.
* @memberOf punycode
* @type String
*/
'version': '2.1.0',

diff --color punycode/package.json node_modules/punycode.js/package.json
2,3c2,3
<   "name": "punycode",
<   "version": "2.1.1",
---
>   "name": "punycode.js",
>   "version": "2.3.0",
34c34
<     "url": "https://github.com/bestiejs/punycode.js.git"
---
>     "url": "https://github.com/mathiasbynens/punycode.js.git"
36c36
<   "bugs": "https://github.com/bestiejs/punycode.js/issues",
---
>   "bugs": "https://github.com/mathiasbynens/punycode.js/issues",
44c44
<     "prepublish": "node scripts/prepublish.js"
---
>     "build": "node scripts/prepublish.js"
49c49
<     "mocha": "^2.5.3"
---
>     "mocha": "^10.2.0"
diff --color punycode/punycode.es6.js node_modules/punycode.js/punycode.es6.js
18c18
< const regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
---
> const regexNonASCII = /[^\0-\x7F]/; // Note: U+007F DEL is excluded too.
53c53
< function map(array, fn) {
---
> function map(array, callback) {
57c57
< 		result[length] = fn(array[length]);
---
> 		result[length] = callback(array[length]);
69c69
<  * @returns {Array} A new string of characters returned by the callback
---
>  * @returns {String} A new string of characters returned by the callback
72,73c72,73
< function mapDomain(string, fn) {
< 	const parts = string.split('@');
---
> function mapDomain(domain, callback) {
> 	const parts = domain.split('@');
79c79
< 		string = parts[1];
---
> 		domain = parts[1];
82,84c82,84
< 	string = string.replace(regexSeparators, '\x2E');
< 	const labels = string.split('.');
< 	const encoded = map(labels, fn).join('.');
---
> 	domain = domain.replace(regexSeparators, '\x2E');
> 	const labels = domain.split('.');
> 	const encoded = map(labels, callback).join('.');
133c133
< const ucs2encode = array => String.fromCodePoint(...array);
---
> const ucs2encode = codePoints => String.fromCodePoint(...codePoints);
145,146c145,146
< 	if (codePoint - 0x30 < 0x0A) {
< 		return codePoint - 0x16;
---
> 	if (codePoint >= 0x30 && codePoint < 0x3A) {
> 		return 26 + (codePoint - 0x30);
148c148
< 	if (codePoint - 0x41 < 0x1A) {
---
> 	if (codePoint >= 0x41 && codePoint < 0x5B) {
151c151
< 	if (codePoint - 0x61 < 0x1A) {
---
> 	if (codePoint >= 0x61 && codePoint < 0x7B) {
231c231
< 		let oldi = i;
---
> 		const oldi = i;
240c240,243
< 			if (digit >= base || digit > floor((maxInt - i) / w)) {
---
> 			if (digit >= base) {
> 				error('invalid-input');
> 			}
> 			if (digit > floor((maxInt - i) / w)) {
294c297
< 	let inputLength = input.length;
---
> 	const inputLength = input.length;
308c311
< 	let basicLength = output.length;
---
> 	const basicLength = output.length;
345c348
< 			if (currentValue == n) {
---
> 			if (currentValue === n) {
362c365
< 				bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
---
> 				bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
diff --color punycode/punycode.js node_modules/punycode.js/punycode.js
18c18
< const regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
---
> const regexNonASCII = /[^\0-\x7F]/; // Note: U+007F DEL is excluded too.
53c53
< function map(array, fn) {
---
> function map(array, callback) {
57c57
< 		result[length] = fn(array[length]);
---
> 		result[length] = callback(array[length]);
69c69
<  * @returns {Array} A new string of characters returned by the callback
---
>  * @returns {String} A new string of characters returned by the callback
72,73c72,73
< function mapDomain(string, fn) {
< 	const parts = string.split('@');
---
> function mapDomain(domain, callback) {
> 	const parts = domain.split('@');
79c79
< 		string = parts[1];
---
> 		domain = parts[1];
82,84c82,84
< 	string = string.replace(regexSeparators, '\x2E');
< 	const labels = string.split('.');
< 	const encoded = map(labels, fn).join('.');
---
> 	domain = domain.replace(regexSeparators, '\x2E');
> 	const labels = domain.split('.');
> 	const encoded = map(labels, callback).join('.');
133c133
< const ucs2encode = array => String.fromCodePoint(...array);
---
> const ucs2encode = codePoints => String.fromCodePoint(...codePoints);
145,146c145,146
< 	if (codePoint - 0x30 < 0x0A) {
< 		return codePoint - 0x16;
---
> 	if (codePoint >= 0x30 && codePoint < 0x3A) {
> 		return 26 + (codePoint - 0x30);
148c148
< 	if (codePoint - 0x41 < 0x1A) {
---
> 	if (codePoint >= 0x41 && codePoint < 0x5B) {
151c151
< 	if (codePoint - 0x61 < 0x1A) {
---
> 	if (codePoint >= 0x61 && codePoint < 0x7B) {
231c231
< 		let oldi = i;
---
> 		const oldi = i;
240c240,243
< 			if (digit >= base || digit > floor((maxInt - i) / w)) {
---
> 			if (digit >= base) {
> 				error('invalid-input');
> 			}
> 			if (digit > floor((maxInt - i) / w)) {
294c297
< 	let inputLength = input.length;
---
> 	const inputLength = input.length;
308c311
< 	let basicLength = output.length;
---
> 	const basicLength = output.length;
345c348
< 			if (currentValue == n) {
---
> 			if (currentValue === n) {
362c365
< 				bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
---
> 				bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
diff --color punycode/README.md node_modules/punycode.js/README.md
1c1
< # Punycode.js [![Build status](https://travis-ci.org/bestiejs/punycode.js.svg?branch=master)](https://travis-ci.org/bestiejs/punycode.js) [![Code coverage status](http://img.shields.io/codecov/c/github/bestiejs/punycode.js.svg)](https://codecov.io/gh/bestiejs/punycode.js) [![Dependency status](https://gemnasium.com/bestiejs/punycode.js.svg)](https://gemnasium.com/bestiejs/punycode.js)
---
> # Punycode.js [![punycode on npm](https://img.shields.io/npm/v/punycode)](https://www.npmjs.com/package/emoji-test-regex-pattern) [![](https://data.jsdelivr.com/v1/package/npm/punycode/badge)](https://www.jsdelivr.com/package/npm/punycode)
15c15
< The current version supports recent versions of Node.js only. It provides a CommonJS module and an ES6 module. For the old version that offers the same functionality with broader support, including Rhino, Ringo, Narwhal, and web browsers, see [v1.4.1](https://github.com/bestiejs/punycode.js/releases/tag/v1.4.1).
---
> This project provides a CommonJS module that uses ES2015+ features and JavaScript module, which work in modern Node.js versions and browsers. For the old Punycode.js version that offers the same functionality in a UMD build with support for older pre-ES2015 runtimes, including Rhino, Ringo, and Narwhal, see [v1.4.1](https://github.com/mathiasbynens/punycode.js/releases/tag/v1.4.1).
26a27,30
> > ⚠️ Note that userland modules don't hide core modules.
> > For example, `require('punycode')` still imports the deprecated core module even if you executed `npm install punycode`.
> > Use `require('punycode/')` to import userland modules rather than core modules.
> 
28c32
< const punycode = require('punycode');
---
> const punycode = require('punycode/');
mathiasbynens added a commit that referenced this issue Oct 30, 2023
@mathiasbynens
Copy link
Owner

version has been updated to align with the package.json version number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants