zloirock/core-js

URL punycode differs from nodejs / chrome behaviour

Open

#1.223 aberto em 17 de mar. de 2023

Ver no GitHub
 (7 comments) (0 reactions) (0 assignees)JavaScript (1.609 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (23.771 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Consider the following url which has non-ascii characters: https://𝚍𝚒𝚜𝚌𝚘𝚛𝚍.gg

While trying to parse this for the hostname, both nodejs and chrome return ascii string discord.gg but corejs returns xn--ci2hbbs5ase.gg

Here is the code:

import configurator from 'core-js-pure/configurator.js';

configurator({
    // By default polyfills are not used if they are available natively.
    usePolyfill: ['URL'], // Override that behaviour for URL.
});

import URL from 'core-js-pure/web/url.js'; // For URL

const url = new URL('https://𝚍𝚒𝚜𝚌𝚘𝚛𝚍.gg');
console.log(url.hostname); 

Guia do colaborador