evancz / url-parser

Parse URLs into nicely structured data
http://package.elm-lang.org/packages/evancz/url-parser/latest/
BSD 3-Clause "New" or "Revised" License
114 stars 29 forks source link

Is there way to get tail of the URL ? #34

Closed deem0n closed 7 years ago

deem0n commented 7 years ago

Hello,

I am a newbie and want to integrate auth phase into my first SPA. My idea is to prefix normal URL with #auth/ so I can send user to the correct page after successfull login.

Example:

  1. User navigates to #/items/123
  2. As result of data fetch request server send back 401 status, so I can know that I need to show login page
  3. I redirect to #/auth/items/123 somehow and display a login page there
  4. User provides correct login and password and I just want to redirect at #/items/123 at this stage

Something like tail would help me a lot:

 parseHash (s "auth" </> tail ) {  hash = "#/auth/items/123", host = "", hostname = "", href ="", origin = "", password="",pathname="", port_="", protocol="", search="", username="" }

Just "items/123" : Maybe.Maybe String

Or is there a better way to do auth redirects ? Thanks!

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 7 years ago

I am tracking this feature request in #40. I'd like to get a broader understanding of all the usage scenarios before making the choice.