Skip to content

Commit

Permalink
Fix encoding "%" as last character
Browse files Browse the repository at this point in the history
closes #1
  • Loading branch information
SeanHayes authored and dougwilson committed Jan 22, 2018
1 parent d668c44 commit a82c78d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
==========

* Fix encoding `%` as last character

1.0.1 / 2016-06-09
==================

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = encodeUrl
* @private
*/

var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]))+/g
var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g

/**
* RegExp to match unmatched surrogate pair.
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('encodeUrl(url)', function () {
})

it('should encode the "%" if not a valid sequence', function () {
assert.equal(encodeUrl('http://localhost/%foo%bar%zap'), 'http://localhost/%25foo%bar%25zap')
assert.equal(encodeUrl('http://localhost/%foo%bar%zap%'), 'http://localhost/%25foo%bar%25zap%25')
})
})

Expand Down

0 comments on commit a82c78d

Please sign in to comment.