browser icon indicating copy to clipboard operation
browser copied to clipboard

Allow custom rules of what is considered Internal/External URL

Open malaire opened this issue 7 years ago • 3 comments

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.

malaire avatar Oct 30 '18 19:10 malaire

Is this not the solution for you?

case urlRequest of
    Browser.Internal url ->
        if isReallyInternal url then
            ...

        else
            ...
       
    Browser.External href ->
          ...

jinjor avatar Oct 31 '18 17:10 jinjor

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

malaire avatar Oct 31 '18 17:10 malaire

+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 )

SergKam avatar Mar 19 '19 08:03 SergKam