Skip to content

Commit

Permalink
Fix decoding %25foo to %foo which is then rejected by GitHub with sta…
Browse files Browse the repository at this point in the history
…tus 400 on Chrome or 500 on FireFox
  • Loading branch information
ilyaigpetrov committed Aug 17, 2023
1 parent 92b868b commit d060977
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bg/10-main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ import { toUnicode } from '../../node_modules/punycode/punycode.es6.js';
let oldHref;
do {
oldHref = newHref;
newHref = decodeURI(newHref
.replace(u.hostname, toUnicode(u.hostname)),
newHref = decodeURI(
newHref
.replace(u.hostname, toUnicode(u.hostname))
/*
Don't decode `%25` to `%` because it causes errors while being put in GitHub URLs.
Test case: https://github.com/ilyaigpetrov/copy-unicode-urls/wiki/Test-%25-and-%3F
*/
.replaceAll('%25', '%2525'),
)
// Encode whitespace.
.replace(
Expand Down Expand Up @@ -100,7 +106,7 @@ import { toUnicode } from '../../node_modules/punycode/punycode.es6.js';
);

// CheckBoxes

options.forEach(([ key, value ], i) =>
createMenuEntry(key, 'checkbox', chrome.i18n.getMessage(key), (info) => {

Expand Down

0 comments on commit d060977

Please sign in to comment.