Skip to content

Commit

Permalink
Do not decode + to a space - fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Dec 13, 2022
1 parent a0eea46 commit 3bbc879
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ module.exports = function (encodedURI) {
}

try {
encodedURI = encodedURI.replace(/\+/g, ' ');

// Try the built in decoder first
return decodeURIComponent(encodedURI);
} catch (err) {
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

## Why?

- Decodes `+` to a space.
- Converts the [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) to a [replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) ``.
- Does not throw with invalid encoded input.
- Decodes as much of the string as possible.
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import m from './';

const tests = {
'test': 'test',
'a+b': 'a b',
'a+b+c+d': 'a b c d',
'a+b': 'a+b',
'a+b+c+d': 'a+b+c+d',
'=a': '=a',
'%': '%',
'%25': '%',
Expand All @@ -20,7 +20,7 @@ const tests = {
'%7 B%ab%%7C%de%%7 D': '%7 B%ab%|%de%%7 D',
'%ab': '%ab',
'%ab%ab%ab': '%ab%ab%ab',
'%61+%4d%4D': 'a MM',
'%61+%4d%4D': 'a+MM',
'\uFEFFtest': '\uFEFFtest',
'\uFEFF': '\uFEFF',
'%EF%BB%BFtest': '\uFEFFtest',
Expand Down

0 comments on commit 3bbc879

Please sign in to comment.