Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-stringprep

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-stringprep - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

test/tounicode.js

22

index.js
'use strict';
// from unicode/uidna.h
var UIDNA_ALLOW_UNASSIGNED = 1
var UIDNA_USE_STD3_RULES = 2
try {

@@ -14,5 +18,7 @@ var bindings = require('bindings')('node_stringprep.node')

var toUnicode = function(value) {
var toUnicode = function(value, options) {
options = options || {}
try {
return bindings.toUnicode(value)
return bindings.toUnicode(value,
(options.allowUnassigned && UIDNA_ALLOW_UNASSIGNED) | 0)
} catch (e) {

@@ -23,7 +29,13 @@ return value

var toASCII = function(value) {
var toASCII = function(value, options) {
options = options || {}
try {
return bindings.toASCII(value)
return bindings.toASCII(value,
(options.allowUnassigned && UIDNA_ALLOW_UNASSIGNED) |
(options.useSTD3Rules && UIDNA_USE_STD3_RULES))
} catch (e) {
return value
if (options.throwIfError)
throw e
else
return value
}

@@ -30,0 +42,0 @@ }

{
"name": "node-stringprep",
"version": "0.5.0",
"version": "0.5.1",
"main": "index.js",

@@ -5,0 +5,0 @@ "description": "ICU StringPrep profiles",

@@ -9,5 +9,28 @@ 'use strict';

var result = SP.toASCII('I\u2665U')
var result = SP.toASCII('i\u2665u')
result.should.equal('xn--iu-t0x')
done()
})
it('Should throw on error', function(done) {
var SP = require('../index')
SP.toASCII.bind(SP, '\ud83d\ude03', { throwIfError: true }).should.throw()
done()
})
it('Should convert unassigned code point', function(done) {
var SP = require('../index')
var result = SP.toASCII('\ud83d\ude03', { allowUnassigned : true })
result.should.equal('xn--h28h')
done()
})
it('Should error on non-STD3 char', function(done) {
var SP = require('../index')
SP.toASCII.bind(SP, 'abc#def', { throwIfError: true, useSTD3Rules: true }).should.throw()
done()
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc