Skip to content

Commit

Permalink
Preserve %EF%B8%8F in GitHub anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornella committed Sep 23, 2020
1 parent 87e4cca commit ee7536f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ results
node_modules
npm-debug.log
tmp
package-lock.json
4 changes: 2 additions & 2 deletions anchor-markdown-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getGithubId(text, repetition) {
}

// Strip emojis
text = text.replace(emojiRegex(), '')
text = text.replace(emojiRegex(), '');

return text;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ module.exports = function anchorMarkdownHeader(header, mode, repetition, moduleN
// encodeURI replaces the zero width joiner character
// (used to generate emoji sequences, e.g.Female Construction Worker 👷🏼‍♀️)
// github doesn't URL encode them, so we replace them after url encoding to preserve the zwj character.
return newURI.replace(/%E2%80%8D/g, '\u200D');
return newURI.replace(/%E2%80%8D/g, '%EF%B8%8F');
};
break;
case 'bitbucket.org':
Expand Down
4 changes: 3 additions & 1 deletion test/anchor-markdown-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ test('\ngenerating anchor in github mode', function (t) {
, [ 'Modules 📦', null, '#modules-']
, [ 'Modu📦les', null, '#modules']
, [ 'Mo📦du📦les', null, '#modules']
, [ '👷🏼‍♀️ Maintenance', null, '#\u200D-maintenance']
, [ '👷🏼‍♀️ Maintenance', null, '#%EF%B8%8F-maintenance']
, [ 'Alarm clock ⏰', null, '#alarm-clock-']
, [ 'Apple Watch ⌚️', null, '#apple-watch-%EF%B8%8F']
].forEach(function (x) { check(x[0], x[1], x[2]) });
t.end();
})
Expand Down

0 comments on commit ee7536f

Please sign in to comment.