Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Rewriting relative URLs #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Rewriting relative URLs #45

wants to merge 2 commits into from

Conversation

dswd
Copy link

@dswd dswd commented Sep 17, 2014

Convert relative URLs embedded in the content to absolute URLs so that they point to the correct destination. This rewrites URLs based on the following rules:

  • If the URL contains a colon like in 'http://' or 'https://' or 'mailto:' it is considered absolute and not rewritten
  • If the URL starts with a hash, it is considered a page-internal anchor that does not have to be rewritten
  • If the URL starts with a double slash, it is considered absolute and not rewritten
  • Anything else that starts with a slash is rewritten by prepending the host part (everything before the first slash, after the first double-slash) of the original URL
  • Anything else is rewritten by prepending the directory part (everything before the last slash) of the original URL

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant