Comparing version 1.0.0 to 1.0.1
module.exports = function pctEncode(regexp) { | ||
regexp = regexp || /\W/g; | ||
return function encode(string) { | ||
@@ -3,0 +4,0 @@ string = String(string); |
{ | ||
"name": "pct-encode", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Percent-encode characters in strings matching a regular expression", | ||
@@ -19,3 +19,37 @@ "main": "index.js", | ||
], | ||
"license": "BSD" | ||
"license": "BSD", | ||
"testling": { | ||
"files": "test.js", | ||
"browsers": { | ||
"iexplore": [ | ||
8, | ||
9, | ||
10 | ||
], | ||
"chrome": [ | ||
"canary" | ||
], | ||
"firefox": [ | ||
"nightly" | ||
], | ||
"opera": [ | ||
"next" | ||
], | ||
"iphone": [ | ||
"6.0" | ||
], | ||
"ipad": [ | ||
"6.0" | ||
], | ||
"safari": [ | ||
"6.0" | ||
], | ||
"android-browser": [ | ||
"4.2" | ||
] | ||
} | ||
}, | ||
"devDependencies": { | ||
"tape": "~2.0.0" | ||
} | ||
} |
@@ -5,11 +5,12 @@ # pct-encode | ||
[![browser support](https://ci.testling.com/grncdr/pct-encode.png)](https://ci.testling.com/grncdr/pct-encode) | ||
## Synopsis | ||
```javascript | ||
var pctEncode = require('pct-encode') | ||
var encode = pctEncode(/\W/); | ||
var encode = pctEncode(/\W/g); | ||
console.log(encode("UTF-8 in your URIs: ✓")); | ||
console.log(encode("UTF-8 in your URIs: ✓")); // UTF-8%20in%20your%20URIs%3A%20%E2%9C%93 | ||
``` | ||
@@ -19,5 +20,5 @@ | ||
# module.exports = function (regexp) -> function (string) | ||
### module.exports = function (regexp) -> function encode(string) | ||
Given a regular expression, this returns a function that takes a string and | ||
returns a copy with characters that match `regexp` percent-encoded. |
15
test.js
@@ -1,9 +0,10 @@ | ||
var assert = require('assert') | ||
var pctEncode = require('./') | ||
var test = require('tape') | ||
var pctEncode = require('./index.js') | ||
var encode = pctEncode(/[^\w~.\-]/g); | ||
test('Does it work?', function (t) { | ||
t.plan(1) | ||
var encode = pctEncode(/[^\w~.\-]/g); | ||
assert.equal(encode("UTF-8 in your URIs: ✓"), | ||
"UTF-8%20in%20your%20URIs%3A%20%E2%9C%93"); | ||
console.log('ok'); | ||
t.equal(encode("UTF-8 in your URIs: ✓✓"), | ||
"UTF-8%20in%20your%20URIs%3A%20%E2%9C%93%E2%9C%93"); | ||
}) |
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
3893
10
59
23
1