Handle baseUrl in live-preview reload check#1594
Merged
Merged
Conversation
Contributor
|
Thanks for the quick fix @ryoarmanda 👍 |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the purpose of this pull request?
Resolves #1583
The problem lies on a mismatch between the HTTP-request routine and the filesystem-watch routine in the
live-serverpatch. During HTTP-request, the URLs - which is used to identify WebSocket clients - actually include thebaseUrl, while during the filesystem-watch, the filepaths of changed files do not. Thus, reloads are unable to be triggered due to lack ofbaseUrl.The solution is to bring the
baseUrlinformation to the patch. Fortunately, we have this information in ourmountproperty of the server configuration, which is used to route paths prefixed bybaseUrlto serve files from the_sitedirectory.For convenience and simplicity for MarkBind use, we now identify WebSocket clients by its normalized url, that is the url without the
baseUrl. That way, when MarkBind callsLiveServer.getActiveUrls(), it will receive urls without needing further processing of removing the base url.Overview of changes:
live-serverpatchbaseUrlproperty to the server objectbaseUrlinitialization duringmountrule applicationAnything you'd like to highlight / discuss:
Review of the general approach is appreciated.
Testing instructions:
Test these on the default site (
markbind init), with defined and emptybaseUrlproperty insite.json:Proposed commit message: (wrap lines at 72 characters)
Handle baseUrl in live-preview reload check
In live-preview, checks are implemented to only reload pages that
correspond to the changed file. However, the comparison used for the
check has not taken into account the base url of the site, which
causes these checks to always fail and thus pages are not automatically
reloaded.
Let's add base url handling to the check, so that sites with specified
can properly benefit from the live-preview feature.
Checklist: ☑️