mirror of https://github.com/luizdepra/hugo-coder.git

Simon Hollingshead
07.41.2023 2bb0a945b6e5b332d2177d55f6af07162e257578
refs
author Simon Hollingshead <me@simonhollingshead.com>
Friday, April 7, 2023 01:41 +0200
committer GitHub <noreply@github.com>
Friday, April 7, 2023 01:41 +0200
commit2bb0a945b6e5b332d2177d55f6af07162e257578
tree 79ec1c368aa462af518727a76a2b657e3fc9aff4 tree | zip | gz
parent 8cf171372753a0dc6c49ef18153dd086fafcebf4 view | diff
Be stricter about what counts as an external link. (#794)

### Prerequisites

Put an `x` into the box(es) that apply:

- [x] This pull request fixes a bug.
- [ ] This pull request adds a feature.
- [ ] This pull request introduces breaking change.

### Description

The current matching of adding the external-link class has both false
positives and false negatives. This attempts to be slightly stricter
about what is an external link.

Before, things like http://foo.com correctly were identified as
external. However:

* A relative link to "http-specification-2.0.pdf" would be considered
external because it starts with 'http'
* HTTP://EXAMPLE.COM is considered internal because 'HTTP' != 'http'
* //example.com (i.e. a protocol-relative destination) is considered
internal because it does not start with 'http'.

This resolves those matters by strictly checking for the '://' in the
forcibly-lowercased version of the destination, and for URLs starting
with two slashes.

### Issues Resolved


### Checklist

Put an `x` into the box(es) that apply:

#### General

- [x] Describe what changes are being made
- [x] Explain why and how the changes were necessary and implemented
respectively
- [ ] Reference issue with `#<ISSUE_NO>` if applicable

#### Resources

- [ ] If you have changed any SCSS code, run `make release` to
regenerate all CSS files

#### Contributors

- [x] Add yourself to `CONTRIBUTORS.md` if you aren't on it already
1 files modified
2 ■■■ changed files
layouts/_default/_markup/render-link.html 2 ●●● diff | view | raw | blame | history