Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SamVerschueren/decode-uri-component
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 52782a347527a6a05fed02434ffcf8f2ba1b19a3
Choose a base ref
...
head repository: SamVerschueren/decode-uri-component
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a0eea469d26eb0df668b081672cdb9581feb78eb
Choose a head ref
  • 8 commits
  • 11 files changed
  • 2 contributors

Commits on Oct 7, 2019

  1. Meta tweaks

    SamVerschueren committed Oct 7, 2019
    Copy the full SHA
    66e1c28 View commit details

Commits on Oct 27, 2019

  1. Tidelift tasks

    SamVerschueren committed Oct 27, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    a650457 View commit details

Commits on Nov 29, 2022

  1. 1
    Copy the full SHA
    486d7e2 View commit details

Commits on Dec 1, 2022

  1. Copy the full SHA
    746ca5d View commit details
  2. Copy the full SHA
    76abc93 View commit details
  3. 0.2.1

    SamVerschueren committed Dec 1, 2022
    Copy the full SHA
    3c8a373 View commit details
  4. Copy the full SHA
    980e0bf View commit details
  5. 0.2.2

    SamVerschueren committed Dec 1, 2022
    1
    Copy the full SHA
    a0eea46 View commit details
Showing with 94 additions and 67 deletions.
  1. +1 −1 .editorconfig
  2. +1 −0 .github/funding.yml
  3. +3 −0 .github/security.md
  4. +27 −0 .github/workflows/main.yaml
  5. +1 −0 .npmrc
  6. +0 −9 .travis.yml
  7. +4 −4 index.js
  8. +4 −16 license
  9. +35 −35 package.json
  10. +14 −1 readme.md
  11. +4 −1 test.js
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tidelift: npm/decode-uri-component
3 changes: 3 additions & 0 deletions .github/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
27 changes: 27 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- '18'
- '16'
- '14'
- '12'
- '10'
- '8'
- '6'
- '4'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
var token = '%[a-f0-9]{2}';
var singleMatcher = new RegExp(token, 'gi');
var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
var multiMatcher = new RegExp('(' + token + ')+', 'gi');

function decodeComponents(components, split) {
try {
// Try to decode the entire string first
return decodeURIComponent(components.join(''));
return [decodeURIComponent(components.join(''))];
} catch (err) {
// Do nothing
}
@@ -28,12 +28,12 @@ function decode(input) {
try {
return decodeURIComponent(input);
} catch (err) {
var tokens = input.match(singleMatcher);
var tokens = input.match(singleMatcher) || [];

for (var i = 1; i < tokens.length; i++) {
input = decodeComponents(tokens, i).join('');

tokens = input.match(singleMatcher);
tokens = input.match(singleMatcher) || [];
}

return input;
20 changes: 4 additions & 16 deletions license
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
The MIT License (MIT)

Copyright (c) Sam Verschueren <sam.verschueren@gmail.com> (github.com/SamVerschueren)
Copyright (c) 2017, Sam Verschueren <sam.verschueren@gmail.com> (github.com/SamVerschueren)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 changes: 35 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
{
"name": "decode-uri-component",
"version": "0.2.0",
"description": "A better decodeURIComponent",
"license": "MIT",
"repository": "SamVerschueren/decode-uri-component",
"author": {
"name": "Sam Verschueren",
"email": "sam.verschueren@gmail.com",
"url": "github.com/SamVerschueren"
},
"engines": {
"node": ">=0.10"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js"
],
"keywords": [
"decode",
"uri",
"component",
"decodeuricomponent",
"components",
"decoder",
"url"
],
"devDependencies": {
"ava": "^0.17.0",
"coveralls": "^2.13.1",
"nyc": "^10.3.2",
"xo": "^0.16.0"
}
"name": "decode-uri-component",
"version": "0.2.2",
"description": "A better decodeURIComponent",
"license": "MIT",
"repository": "SamVerschueren/decode-uri-component",
"author": {
"name": "Sam Verschueren",
"email": "sam.verschueren@gmail.com",
"url": "github.com/SamVerschueren"
},
"engines": {
"node": ">=0.10"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js"
],
"keywords": [
"decode",
"uri",
"component",
"decodeuricomponent",
"components",
"decoder",
"url"
],
"devDependencies": {
"ava": "^0.17.0",
"coveralls": "^2.13.1",
"nyc": "^10.3.2",
"xo": "^0.16.0"
}
}
15 changes: 14 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# decode-uri-component

[![Build Status](https://travis-ci.org/SamVerschueren/decode-uri-component.svg?branch=master)](https://travis-ci.org/SamVerschueren/decode-uri-component) [![Coverage Status](https://coveralls.io/repos/SamVerschueren/decode-uri-component/badge.svg?branch=master&service=github)](https://coveralls.io/github/SamVerschueren/decode-uri-component?branch=master)
![CI](https://github.com/SamVerschueren/decode-uri-component/workflows/CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/SamVerschueren/decode-uri-component/badge.svg?branch=master&service=github)](https://coveralls.io/github/SamVerschueren/decode-uri-component?branch=master)

> A better [decodeURIComponent](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
@@ -68,3 +68,16 @@ An encoded component of a Uniform Resource Identifier.
## License

MIT © [Sam Verschueren](https://github.com/SamVerschueren)


---

<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-decode-uri-component?utm_source=npm-decode-uri-component&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
5 changes: 4 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -32,7 +32,10 @@ const tests = {
'%C2x': '\uFFFDx',
'%C2%B5': 'µ',
'%C2%B5%': 'µ%',
'%%C2%B5%': '%µ%'
'%%C2%B5%': '%µ%',
'%ea%ba%5a%ba': '%ea%baZ%ba',
'%C3%5A%A5': '%C3Z%A5',
'%C3%5A%A5%AB': '%C3Z%A5%AB'
};

function macro(t, input, expected) {