fix: avoid infinite loop when hitting an inexistent route #49
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.
closes #48
Testing the pr
When testing the pr, remember to
ElmBook.ThemeOptions.useHashBasedNavigation
in the UI/ElmBook.elm fileFYI: The links must be in this format
#/guides/inexistent
Rationale
When hashBasedNavigation is true and a route that can't be found among the chapters is hit, this is what happens:
extractPath url_
is called and returns/guides/inexistent
(url.fragment) which is then assigned tourl
Nothing
caseNothing
case navigates to#/
extractPath url_
is called and returns/
(url.fragment
isNothing
henceMaybe.withDefault
kicks in) which is then assigned tourl
/overview
in the case of this repo) and navigates there, which is a problem because we have hashBasedNavigation set to trueextractPath url_
is called and when hashBasedNavigation is true it returns the fragment or/
and in the case of/overview
the fragment is Nothing.Solution
How do we stop it? Should be simple honestly, when the fallback chapter is retrieved, let's add the hashtag on front.
Screencast
Screen.Recording.2024-08-22.at.00.29.09.mov