Coder Social home page Coder Social logo

tr46's Introduction

tr46

An JavaScript implementation of Unicode Technical Standard #46: Unicode IDNA Compatibility Processing.

API

toASCII(domainName[, options])

Converts a string of Unicode symbols to a case-folded Punycode string of ASCII symbols.

Available options:

toUnicode(domainName[, options])

Converts a case-folded Punycode string of ASCII symbols to a string of Unicode symbols.

Available options:

Options

checkBidi

Type: boolean Default value: false When set to true, any bi-directional text within the input will be checked for validation.

checkHyphens

Type: boolean Default value: false When set to true, the positions of any hyphen characters within the input will be checked for validation.

checkJoiners

Type: boolean Default value: false When set to true, any word joiner characters within the input will be checked for validation.

ignoreInvalidPunycode

Type: boolean Default value: false When set to true, invalid Punycode strings within the input will be allowed.

transitionalProcessing

Type: boolean Default value: false When set to true, uses transitional (compatibility) processing of the deviation characters.

useSTD3ASCIIRules

Type: boolean Default value: false When set to true, input will be validated according to STD3 Rules.

verifyDNSLength

Type: boolean Default value: false When set to true, the length of each DNS label within the input will be checked for validation.

tr46's People

Contributors

breeeew avatar dependabot[bot] avatar domenic avatar imcotton avatar kraynel avatar sebmaster avatar stevenvachon avatar timothygu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tr46's Issues

Create LICENSE file

Would you please create a LICENSE file with your copyright information and the text of the MIT license? The MIT license actually requires that the license text accompany the source code. Thanks!

Punycode deprecated

The punycode package is deprecated, which generates a warning on start-up.
The suggested workaround on the package's repo is to import it as require('punycode/') instead of require('punycode').
In my testing this seems to resolve the warning, at least in my case.

toAscii and Unicode tests are failing

Description

Two tests fail.

✖ failing tests:

✖ /home/../tr46/test/toascii.js (95.585125ms)
  Error [ERR_TAP_LEXER_ERROR]: Unexpected character: ‍ at line 1, column 0
      at Socket.emit (node:events:511:28) {
    code: 'ERR_TAP_LEXER_ERROR'
  }

✖ /home/../tr46/test/unicode.js (288.905067ms)
  Error [ERR_TAP_LEXER_ERROR]: Unexpected character: ̀ at line 1, column 0
      at Socket.emit (node:events:511:28) {
    code: 'ERR_TAP_LEXER_ERROR'
  }

Reproduce

  1. Clone tr46.
  2. npm run test
  3. Verify failing tests.

Check if usage of split fails in Unicode

Currently split is used to break apart the labels of the domain, however split might break apart at the wrong positions if a dot is position right after a surrogate character(?) maybe/probably.

Remove "punycode" dependency as it is deprecated.

Punycode is deprecated.

(node:53980) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

It's imported here:

const punycode = require("punycode/");

const punycode = require("punycode/");

It's also used a few times inside of the index.js file.

Stripping the FE0F Variation selector 16 modifier when resolving, causing major issues in the cryptocurrency space

I believe there is a discrepancy that is not allowing for standardizing normalisation between several large platforms and markets in the space

It appears someone is not applying the stand in compliance or doing things slightly different
most specifically the library strips FE0F code away when resolving displaying from a few native emojis with joiners and FE0F

https://unicode.org/Public/emoji/14.0/emoji-test.txt
According to this, FE0F should be preserved to be "fully qualified", which is theoretically the more adaptive version, this is currently causing major issues with decentralized emoji domains (.eth) in Opensea , Etherscan and Metawallet, everyone is using a different library and there is no standardization) more specifically Metawallet (which uses this library) resolves differently than Opensea and Etherscan

Taking the example of emoji (genie male) taken directly from unicode.org

1F9DE 200D 2642 FE0F ; fully-qualified # 🧞‍♂️ E5.0 man genie

If you were to take the man genie 🧞‍♂️ ( Hand held devices/Discord/Twitter etc etc will default to 1F9DE 200D 2642 FE0F) large markets like Opensea and Etherscan too. However after this script runs, the strip takes place, we are left with 1F9DE 200D 2642 It strips the FE0F from the man genie turning it into a minimally-qualified emoji. This is disrupting all of the emoji .eth domains, their connection with Metawallet addresses.

It would appear the wisest solution would hopefully try to apply the stand and more widely supported emoji version which in this case is the fully-qualified 1F9DE 200D 2642 FE0F the variation selector 16 modifier shouldn't be stripped away, as its responsible for current and likely future generations of aesthetically different emojis while being the arguably better choice for Unicode stand

Regards

[Deprecation] `punycode` deprecation in Node 21+

The problem here is that punycode from standard library is now deprecated in node version 21+.

This shows the following error:

(node:24289) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Error on iPad Air 2, iOS 8 in safari

Get an error on iPad Air 2 iOS 8 in safari browser
Unexpected keyword 'const'. Const declarations are not supported in strict mode.

    "../../node_modules/tr46/index.js": /*!***************************************************************!*\
  !*** /PATH/node_modules/tr46/index.js ***!
  \***************************************************************/
    /*! no static exports found */
    /***/
    (function(module, exports, __webpack_require__) {

        "use strict";

        const punycode = __webpack_require__(/*! punycode */
        "../../node_modules/node-libs-browser/node_modules/punycode/punycode.js");
        const regexes = __webpack_require__(/*! ./lib/regexes.js */
        "../../node_modules/tr46/lib/regexes.js");
        const mappingTable = __webpack_require__(/*! ./lib/mappingTable.json */
        "../../node_modules/tr46/lib/mappingTable.json");

        function containsNonASCII(str) {
            return /[^\x00-\x7F]/.test(str);
        }

Deprecation issue with the 'punycode' module

Hello,

I am encountering a deprecation issue with the punycode module in your project. The warning message is as follows:

(node:19880) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.

Could you consider updating your project to use a more recent version of punycode (e.g., [email protected])?

Thank you in advance for your help.

Best regards,
valorisa

It is not bundled with Rollup

tr46 is not bundled with Rollup. It seems that the generated JSON file is not imported correctly.

Here is the reproduction:
https://github.com/atom-ide-community/terminal/tree/rollup-bump

npm install
npm run build
[!] Error: 'default' is not exported by node_modules\tr46\lib\mappingTable.json, imported by C:\terminal\node_modules\tr46\lib\mappingTable.json?commonjs-proxy
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
C:\terminal\node_modules\tr46\lib\mappingTable.json?commonjs-proxy (1:8)
1: export {default} from "C:\\terminal\\node_modules\\tr46\\lib\\mappingTable.json";
           ^
Error: 'default' is not exported by node_modules\tr46\lib\mappingTable.json, imported by C:\terminal\node_modules\tr46\lib\mappingTable.json?commonjs-proxy
    at error (C:\terminal\node_modules\rollup\dist\shared\rollup.js:5252:30)
    at Module.error (C:\terminal\node_modules\rollup\dist\shared\rollup.js:9811:16)
    at handleMissingExport (C:\terminal\node_modules\rollup\dist\shared\rollup.js:9700:28)
    at Module.getVariableForExportName (C:\terminal\node_modules\rollup\dist\shared\rollup.js:9987:24)
    at Module.traceVariable (C:\terminal\node_modules\rollup\dist\shared\rollup.js:10202:45)
    at ModuleScope.findVariable (C:\terminal\node_modules\rollup\dist\shared\rollup.js:8732:39)
    at FunctionScope.findVariable (C:\terminal\node_modules\rollup\dist\shared\rollup.js:2782:38)
    at ChildScope.findVariable (C:\terminal\node_modules\rollup\dist\shared\rollup.js:2782:38)
    at MemberExpression.bind (C:\terminal\node_modules\rollup\dist\shared\rollup.js:6436:49)
    at BinaryExpression.bind (C:\terminal\node_modules\rollup\dist\shared\rollup.js:2868:23)

npm ERR! code 1
npm ERR! path C:\terminal
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "npm run clean && cross-env NODE_ENV=production cross-env BABEL_KEEP_MODULES=true rollup -c"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\aminy\AppData\Roaming\npm-cache\_logs\2020-11-06T11_00_18_550Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] prepare: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\aminy\AppData\Roaming\npm-cache\_logs\2020-11-06T11_00_18_595Z-debug.log

replace deprecated punycode dependency

Node v21 starts to loudly protest about punycode being deprecated:

(node:69587) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.

Downstream dependencies would surely appreciate an update addressing this.

Missing LICENSE file in the repo of ver 0.0.3

Currently I'm using tr46 version 0.0.3, but can't find a LICENSE file in the repo of ver 0.0.3.
Could you add the LICENSE file in the repo of ver 0.0.3?
Or is it possible to use the LICENSE file of the latest version as the license for ver 0.0.3?
Thanks in advance.

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.