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

pct-encode

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pct-encode - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.travis.yml

1

index.js
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"
}
}

13

README.md

@@ -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.

@@ -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");
})
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