All Projects → evancz → Url Parser

evancz / Url Parser

Licence: bsd-3-clause
Parse URLs into nicely structured data

Programming Languages

elm
856 projects

Projects that are alternatives of or similar to Url Parser

url
Build and parse URLs. Useful for HTTP and "routing" in single-page apps (SPAs)
Stars: ✭ 69 (-41.53%)
Mutual labels:  url, spa, routing
Frontexpress
An Express.js-Style router for the front-end
Stars: ✭ 263 (+122.88%)
Mutual labels:  url, navigation, spa
Mapbox Directions Swift
Traffic-aware directions and map matching in Swift on iOS, macOS, tvOS, watchOS, and Linux
Stars: ✭ 115 (-2.54%)
Mutual labels:  routing, navigation
Ffrouter
Powerful and easy-to-use URL routing library in iOS that supports URL Rewrite(强大、易用、支持 URL Rewrite的 iOS 路由库)
Stars: ✭ 263 (+122.88%)
Mutual labels:  routing, url
Nested Navigation Demo Flutter
Nested navigation with BottomNavigationBar
Stars: ✭ 367 (+211.02%)
Mutual labels:  routing, navigation
ASMapLauncher
ASMapLauncher is a library for iOS written in Swift that helps navigation with various mapping applications.
Stars: ✭ 41 (-65.25%)
Mutual labels:  navigation, routing
Navigation
Routing for SPAs, the Elm way
Stars: ✭ 255 (+116.1%)
Mutual labels:  routing, spa
Abstract State Router
Like ui-router, but without all the Angular. The best way to structure a single-page webapp.
Stars: ✭ 288 (+144.07%)
Mutual labels:  routing, spa
routing-py
🌎 Python library to access all public routing, isochrones and matrix APIs in a consistent manner.
Stars: ✭ 106 (-10.17%)
Mutual labels:  navigation, routing
Compass
🌍 Compass helps you setup a central navigation system for your application
Stars: ✭ 828 (+601.69%)
Mutual labels:  url, navigation
Findme
An ARKit App that can help your friends to find you
Stars: ✭ 483 (+309.32%)
Mutual labels:  routing, navigation
Bidi
Bidirectional URI routing
Stars: ✭ 941 (+697.46%)
Mutual labels:  routing, url
go router
The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
Stars: ✭ 380 (+222.03%)
Mutual labels:  navigation, routing
dowels
🔨 a tiny but powerful javascript library that performs client-side routing, templating, and REST API communication to help you get your single-page web applications running in seconds
Stars: ✭ 13 (-88.98%)
Mutual labels:  spa, routing
ors-map-client
Openrouteservice API web SPA client using VueJS, Vuetify and Vue2Leaflet
Stars: ✭ 51 (-56.78%)
Mutual labels:  spa, routing
Django Multiurl
Have you ever wanted multiple views to match to the same URL? Now you can.
Stars: ✭ 268 (+127.12%)
Mutual labels:  routing, url
React Easy Params
🔗 Auto synchronize your state with the URL and LocalStorage.
Stars: ✭ 73 (-38.14%)
Mutual labels:  routing, url
demo-ionic-tab-routing
An Ionic project which shows different kinds of route definition for a tab based layout.
Stars: ✭ 34 (-71.19%)
Mutual labels:  navigation, routing
navigation-bar-with-feliz
Modern navigation bar built with Feliz
Stars: ✭ 20 (-83.05%)
Mutual labels:  spa, navigation
Router
🛣 Simple Navigation for iOS
Stars: ✭ 438 (+271.19%)
Mutual labels:  routing, navigation

URL Parser

This library helps you turn URLs into nicely structured data.

It is designed to be used with elm-lang/navigation to help folks create single-page applications (SPAs) where you manage browser navigation yourself.

Note: This library is meant to serve as a baseline for future URL parsers. For example, it does not handle query parameters and hashes right now. It is more to (1) get folks started using URL parsers and (2) help us gather data on exactly which scenarios people face.

Examples

Here is a simplified REPL session showing a parser in action:

> import UrlParser exposing ((</>), s, int, string, parseHash)

> parseHash (s "blog" </> int) { ... , hash = "#blog/42" }
Just 42

> parseHash (s "blog" </> int) { ... , hash = "#/blog/13" }
Just 13

> parseHash (s "blog" </> int) { ... , hash = "#/blog/hello" }
Nothing

> parseHash (s "search" </> string) { ... , hash = "#search/dogs" }
Just "dogs"

> parseHash (s "search" </> string) { ... , hash = "#/search/13" }
Just "13"

> parseHash (s "search" </> string) { ... , hash = "#/search" }
Nothing

Normally you have to put many of these parsers to handle all possible pages though! The following parser works on URLs like /blog/42 and /search/badger:

import UrlParser exposing (Parser, (</>), s, int, string, map, oneOf, parseHash)

type Route = Blog Int | Search String

route : Parser (Route -> a) a
route =
  oneOf
    [ map Blog (s "blog" </> int)
    , map Search (s "search" </> string)
    ]

-- parseHash route { ... , hash = "#/blog/58" }    == Just (Blog 58)
-- parseHash route { ... , hash = "#/search/cat" } == Just (Search "cat")
-- parseHash route { ... , hash = "#/search/31" }  == Just (Search "31")
-- parseHash route { ... , hash = "#/blog/cat" }   == Nothing
-- parseHash route { ... , hash = "#/blog" }       == Nothing

Notice that we are turning URLs into nice union types, so we can use case expressions to work with them in a nice way.

Check out the examples/ directory of this repo to see this in use with elm-lang/navigation.

Testing

npm install
npm test

Background

I first saw this general idea in Chris Done’s formatting library. Based on that, Noah and I outlined the API you see in this library. Noah then found Rudi Grinberg’s post about type safe routing in OCaml. It was exactly what we were going for. We had even used the names s and (</>) in our draft API! In the end, we ended up using the “final encoding” of the EDSL that had been left as an exercise for the reader. Very fun to work through!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].