This repository was archived by the owner on Feb 25, 2021. It is now read-only.
Repository navigation
Clean up use of relative URLs. Fixes #844 and #845 - #878
Merged
Merged
Conversation
Needed to change the URLs used in E2E tests to be able to cover this (i.e., removed the /RouterTest prefixes so the default relative URL became an empty string)
Hence also change terminology from "base URI prefix" to simply "base URI"
SteveSandersonMS
added a commit
to SteveSandersonMS/BlazorMigration
that referenced
this pull request
Nov 27, 2018
* Handle links to empty-string href, resolved against base href Needed to change the URLs used in E2E tests to be able to cover this (i.e., removed the /RouterTest prefixes so the default relative URL became an empty string) * Change links in StandaloneApp sample to be relative * Standardize on base URIs having trailing slash everywhere Hence also change terminology from "base URI prefix" to simply "base URI" * Handle link highlighting when visiting base-href-but-without-trailing-slash * Removing leading slashes from base-relative URLs in templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously we were handling relative URLs in various inconsistent ways. Sometimes they were assumed to start with slashes, and other times they were assumed not to do so. Likewise, APIs that were meant to match or return relative URLs did inconsistent things.
In this PR I've done a pass through (hopefully) everything that is or handles relative URLs, standardizing on a consistent pattern that:
<base href>value must do, if it's going to behave as people expect)There are still a couple of edge cases:
/somedir/, we want anyone visitinghttp://yoursite/somedirto be treated the same as if they were visitinghttp://yoursite/somedir/(i.e., so the same page would be selected and the same nav links would be highlighted). That's because devs often don't have control over the webserver config and might not be able to enforce the trailing slash as canonical.@pagedirective, people will still typically give values with leading-slashes (e.g.,@page "/", not@page ""). We ignore the presence or absence of a leading slash there, because it could never have any meaning, and because people will find it hard to understand what an empty string value would mean.Altogether this fixes #844 and #845, plus is just more consistent internally.
@rynowak @javiercn I'm adding you for review, but I know the contents here won't be hugely interesting as it has limited overlap with your areas. Totally fine if you want to ignore this - I'll just merge it tomorrow unless anyone raises specific concerns.