-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: tup-694 abs URLs to same domain should be rel #811
fix: tup-694 abs URLs to same domain should be rel #811
Conversation
const links = document.getElementsByTagName('a'); | ||
const links = document.querySelectorAll('body > :is(header, main, footer) a'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? So that CMS Admin UI toolbar links are not affected. I noticed the placeholder snippet version of this PR was breaking the CMS Admin UI toolbar.
@@ -18,8 +20,10 @@ export default function findLinksAndSetTargets() { | |||
} | |||
|
|||
const isMailto = ( link.href.indexOf('mailto:') === 0 ); | |||
const isAbsolute = (link.href.indexOf('http') === 0); | |||
const isSameHost = link.host === baseDocHost || link.host === baseDocHostWithSubdomain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New name? Yes. Renamed in noop polish PR #810.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and worked for me.
Overview
Make
setTargetForExternalLinks
also change link URL to relative if it is absolute yet on same host.Related
Changes
setTargetForExternalLinks
Testing
Set up:
Check out branch
fix/tup-694-absolute-urls-to-same-domain-should-be-relative
.Update local CMS with new code (e.g. rebuild or "collectstatic").
Commands
make stop && make build && make start
docker-compose -f ./docker-compose.dev.yml up --detach && docker exec -it core_cms sh -c "python manage.py collectstatic --no-input"
Open CMS e.g. http://localhost:8000/.
Test fix:
href
with absolute path.href
with a relative path.UI