Browse Source

Don't decode %25 in beautified urls

fix https://github.com/markdown-it/markdown-it/issues/720
pull/722/head
Alex Kocharin 4 years ago
parent
commit
f156ed1bff
  1. 1
      CHANGELOG.md
  2. 3
      lib/index.js
  3. 9
      test/fixtures/markdown-it/normalize.txt

1
CHANGELOG.md

@ -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

3
lib/index.js

@ -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 + '%');
}

9
test/fixtures/markdown-it/normalize.txt

@ -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:
.

Loading…
Cancel
Save