Comparing version
'use strict'; | ||
var StringPrep = require('node-stringprep'); | ||
var punycode = require('punycode'); | ||
try { | ||
var StringPrep = require('node-stringprep'); | ||
// We still might not be able to use proper StringPrep, | ||
// so we create a test instance and check if the native | ||
// option is available. | ||
exports.available = new StringPrep.StringPrep('nodeprep').isNative(); | ||
exports.toUnicode = function (data) { | ||
return punycode.toUnicode(StringPrep.toUnicode(data)); | ||
}; | ||
exports.nameprep = function (str) { | ||
var prep = new StringPrep.StringPrep('nameprep'); | ||
return prep.prepare(str); | ||
}; | ||
exports.nodeprep = function (str) { | ||
var prep = new StringPrep.StringPrep('nodeprep'); | ||
return prep.prepare(str); | ||
}; | ||
exports.resourceprep = function (str) { | ||
var prep = new StringPrep.StringPrep('resourceprep'); | ||
return prep.prepare(str); | ||
}; | ||
// We still might not be able to use proper StringPrep, | ||
// so we create a test instance and check if the native | ||
// option is available. | ||
exports.available = new StringPrep.StringPrep('nodeprep').isNative(); | ||
exports.toUnicode = function (data) { | ||
return punycode.toUnicode(StringPrep.toUnicode(data)); | ||
}; | ||
exports.nameprep = function (str) { | ||
var prep = new StringPrep.StringPrep('nameprep'); | ||
return prep.prepare(str); | ||
}; | ||
exports.nodeprep = function (str) { | ||
var prep = new StringPrep.StringPrep('nodeprep'); | ||
return prep.prepare(str); | ||
}; | ||
exports.resourceprep = function (str) { | ||
var prep = new StringPrep.StringPrep('resourceprep'); | ||
return prep.prepare(str); | ||
}; | ||
} catch (err) { | ||
exports.available = false; | ||
exports.toUnicode = punycode.toUnicode; | ||
exports.nameprep = function (str) { | ||
return str.toLowerCase(); | ||
}; | ||
exports.nodeprep = function (str) { | ||
return str.toLowerCase(); | ||
}; | ||
exports.resourceprep = function (str) { | ||
return str; | ||
}; | ||
} |
{ | ||
"name": "xmpp-jid", | ||
"description": "Parse XMPP URIs", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"author": "Lance Stout <lance@andyet.net>", | ||
@@ -11,5 +11,7 @@ "browser": { | ||
"dependencies": { | ||
"node-stringprep": "^0.7.0", | ||
"punycode": "^1.3.0" | ||
}, | ||
"optionalDependencies": { | ||
"node-stringprep": "^0.7.0" | ||
}, | ||
"devDependencies": { | ||
@@ -16,0 +18,0 @@ "browserify": "^9.0.0", |
29822
1.64%610
2.35%- Removed