Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion q.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
});
};

var regexUnsafeSymbols = /[\0-\x1F"-\),\.:-@\[-\^`\{-\uFFFF]/g;
var regexUnsafeSymbols = /[\0-\x1F"-\),\.:-@\[-_`\{-\uFFFF]/g;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove \^?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me re-review.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally getting back to this. Yes, that was deliberate!

It isn't actually removing the caret ^ because you had the character range [ through ^ (U+005B to U+005E) and by substituting the _ (U+005F) the range is now U+005B to U+005F, still including U+005E.

Of course the character range

\[-_

could be further simplified to

\[-`

(U+005B to U+0060, inclusive) but was trying to be unintrusive.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking in on this.

var encode = function(string) {
// Note: this assumes the input is already encoded into octets (e.g. using
// UTF-8), and that the resulting octets are within the extended ASCII
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
'ooh=3A_ahh',
'colons'
);
equal(
q.encode('my dog_has fleas'),
'my_dog=5Fhas_fleas',
'underscore roundtrip, disambiguate from original space'
)
raises(
function() {
// Note: “forgot” to UTF-8-encode first
Expand Down