Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom rules of what is considered Internal/External URL #48

Open
malaire opened this issue Oct 30, 2018 · 3 comments
Open

Allow custom rules of what is considered Internal/External URL #48

malaire opened this issue Oct 30, 2018 · 3 comments

Comments

@malaire
Copy link

malaire commented Oct 30, 2018

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.

@jinjor
Copy link

jinjor commented Oct 31, 2018

Is this not the solution for you?

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

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

@malaire
Copy link
Author

malaire commented Oct 31, 2018

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: elm/url#19

@SergKam
Copy link

SergKam commented Mar 19, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants