Skip to content

Commit

Permalink
Don't decode %25 in beautified urls
Browse files Browse the repository at this point in the history
fix #720
  • Loading branch information
rlidwka committed Oct 14, 2020
1 parent 446bbcf commit f156ed1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix mappings for table rows (amended fix made in 11.0.1), #705.
- `%25` is no longer decoded in beautified urls, #720.


## [11.0.1] - 2020-09-14
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Expand Up @@ -81,7 +81,8 @@ function normalizeLinkText(url) {
}
}

return mdurl.decode(mdurl.format(parsed));
// add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720
return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + '%');
}


Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/markdown-it/normalize.txt
Expand Up @@ -13,6 +13,15 @@ Encode link destination, decode text inside it:
<p><a href="http://example.com/%CE%B1%CE%B2%CE%B3%CE%B4">foo</a></p>
.


Keep %25 as is because decoding it may break urls, #720
.
<https://www.google.com/search?q=hello%2E%252Ehello>
.
<p><a href="https://www.google.com/search?q=hello%2E%252Ehello">https://www.google.com/search?q=hello.%252Ehello</a></p>
.


Should decode punycode:

.
Expand Down

0 comments on commit f156ed1

Please sign in to comment.