browser
browser copied to clipboard
Allow custom rules of what is considered Internal/External URL
Not every application takes control of whole domain. If application lives e.g. under path https://example.com/myapp then URL https://example.com/otherapp needs to be considered to be an external url.
Is this not the solution for you?
case urlRequest of
Browser.Internal url ->
if isReallyInternal url then
...
else
...
Browser.External href ->
...
It's just that whole Internal/External distinction becomes useless if I need to manually check the URL anyway. So if this can't be done in Browser, then Internal/External distinction should be removed.
Also writing that isReallyInternal isn't trivial currently as Url.Parser doesn't seem to support parsers which only match beginning of URL, but that's an issue for Url: https://github.com/elm/url/issues/19
+1 The same use-case
UrlChangeRequested request ->
case request of
Internal location ->
let
-- Checking pseudo-external urls (like /api/*, /auth/*, etc)
cmd =
if location.path == Config.urlBase then
location
|> locationToRoute
|> Redirect
|> dispatch
else
location
|> Url.toString
|> External
|> UrlChangeRequested
|> dispatch
in
( model, cmd )
External url ->
( model, Nav.load url )