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

add alternative methods to handle a basepath like "some/path/" #14

Open
sporto opened this issue Sep 6, 2018 · 4 comments
Open

add alternative methods to handle a basepath like "some/path/" #14

sporto opened this issue Sep 6, 2018 · 4 comments
Labels

Comments

@sporto
Copy link
Contributor

sporto commented Sep 6, 2018

Consider an application that is not in the root of a site e.g.

example.com/some/path/

In this case we would pass the basepath to the app via flags. e.g

flags =
    {
    basePath = "some/path/"
    }

I attempted to parse this like:

matchers : Parser (Route -> a) a
matchers =
    Parser.s flags.basePath  </> Parser.oneOf
        [ Parser.map Home Parser.top
        , Parser.map About (Parser.s "about")
        ]

But Parser.s won't parse the /.

Example here https://ellie-app.com/3grXTSD4Bkxa1

It would be great to have something to parse a basepath e.g.

matchers : Parser (Route -> a) a
matchers =
    Parser.base flags.basePath  </> Parser.oneOf
        [ Parser.map Home Parser.top
        , Parser.map About (Parser.s "about")
        ]

Thanks

@sporto
Copy link
Contributor Author

sporto commented Sep 6, 2018

One workaround is to remove the basepath manually before parsing e.g.

urlWithoutBasePath =
   { url |
      path = String.replace flags.basePath "" url.path
   }

@malaire
Copy link

malaire commented Oct 31, 2018

That workaround completely ignores the problem of percent-encoding.

@ashishsc
Copy link

I'm experiencing this issue as well on a github-pages site

@Erudition
Copy link

That workaround completely ignores the problem of percent-encoding.

...Then percent-encode the base path first.

@evancz evancz added the request label Feb 9, 2021
@evancz evancz changed the title Basepath add alternative methods to handle a basepath like "some/path/" Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants