phpurlencode
Advanced tools
Comparing version 1.0.0 to 1.0.1
19
index.js
"use strict"; | ||
function encode(str) { | ||
return encodeURIComponent(str) | ||
const encode = str => { | ||
return encodeURIComponent(str + '') | ||
.replace(/[!'()]/g, escape) | ||
.replace(/\*/g, "%2A") | ||
.replace(/\%20/g, "+"); | ||
} | ||
.replace(/\%20/g, "+") | ||
.replace(/~/g, '%7E'); | ||
}; | ||
function decode(str) { | ||
return decodeURIComponent(str.replace(/\+/g, " ").replace(/\%2A/g, "*")); | ||
} | ||
const decode = str => { | ||
return decodeURIComponent( | ||
(str + '') | ||
.replace(/%(?![\da-f]{2})/gi, () => '%25') | ||
.replace(/\+/g, '%20') | ||
); | ||
}; | ||
@@ -13,0 +18,0 @@ module.exports = encode; |
{ | ||
"name": "phpurlencode", | ||
"description": "Functionally similar to PHP urlencode and urldecode functions", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "index.js", | ||
@@ -16,3 +16,4 @@ "license": "MIT", | ||
"url": "https://github.com/luke3butler/node-phpurlencode.git" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -11,4 +11,4 @@ "use strict"; | ||
assert.equal( | ||
"%21%40%23%24%25%5E%26%2A%28%29%2B%27", | ||
urlencode("!@#$%^&*()+'") | ||
"%21%40%23%24%25%5E%26%2A%28%29%2B%27%7E%22%3C%3E%2C.", | ||
urlencode("!@#$%^&*()+'~\"<>,.") | ||
); | ||
@@ -32,4 +32,4 @@ } | ||
assert.equal( | ||
"!@#$%^&*()+'", | ||
urlencode.decode("%21%40%23%24%25%5E%26%2A%28%29%2B%27") | ||
"!@#$%^&*()+'~\"<>,.", | ||
urlencode.decode("%21%40%23%24%25%5E%26%2A%28%29%2B%27%7E%22%3C%3E%2C.") | ||
); | ||
@@ -36,0 +36,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4485
61