mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-24 04:12:09 +03:00
Fix missing content flash for paths that weren't normalized correctly.
This commit is contained in:
parent
4ea2e47e98
commit
5b12ab452d
@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- Fix missing content flash (that was partially fixed with [#48](https://github.com/dillonkearns/elm-pages/pull/48)) for
|
||||
some cases where paths weren't normalized correctly.
|
||||
|
||||
## [1.1.8] - 2020-01-20
|
||||
|
||||
### Fixed
|
||||
|
@ -175,7 +175,7 @@ parseMetadata maybeInitialPageContent document content =
|
||||
in
|
||||
case maybeInitialPageContent of
|
||||
Just { contentJson, initialUrl } ->
|
||||
if initialUrl.path == ("/" ++ String.join "/" path) then
|
||||
if normalizePath initialUrl.path == (String.join "/" path |> normalizePath) then
|
||||
Parsed metadata
|
||||
{ body = renderer contentJson.body
|
||||
, staticData = contentJson.staticData
|
||||
@ -195,6 +195,30 @@ parseMetadata maybeInitialPageContent document content =
|
||||
)
|
||||
|
||||
|
||||
normalizePath : String -> String
|
||||
normalizePath pathString =
|
||||
let
|
||||
hasPrefix =
|
||||
String.startsWith "/" pathString
|
||||
|
||||
hasSuffix =
|
||||
String.endsWith "/" pathString
|
||||
in
|
||||
String.concat
|
||||
[ if hasPrefix then
|
||||
""
|
||||
|
||||
else
|
||||
"/"
|
||||
, pathString
|
||||
, if hasSuffix then
|
||||
""
|
||||
|
||||
else
|
||||
"/"
|
||||
]
|
||||
|
||||
|
||||
parseContent :
|
||||
String
|
||||
-> String
|
||||
|
Loading…
Reference in New Issue
Block a user