Name: urlshaper
Owner: Honeycomb
Description: null
Created: 2016-09-21 20:32:40.0
Updated: 2018-02-12 19:28:09.0
Pushed: 2017-03-02 20:20:28.0
Homepage: null
Size: 11
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
URL Shaper is a go library that takes a URL path and query and breaks it up into its components and creates a shape.
URL Shaper will generate a URL Shape by taking a URL and making a number of changes to it to make it easier to do analysis on URL patterns:
In addition to the URL shape, the Result object you get back from URL Shaper contains
Parameters in the path portion of the URL are identified by matching the URL against a list of provided patterns. Patterns are matched in the order provided; the first match wins. Patterns should represent the entire path portion of the URL - include a “*” at the end to match arbitrary additional segments.
input:
/about/en/books?isbn=123456&author=Alice
output:
/about/en/books?isbn=123456&author=Alice
/about/en/books
isbn=123456&author=Alice
{"isbn":["123456"],"author":["Alice"]}
{}
/about/en/books?author=?&isbn=?
input:
/about/en/books/123456
/about/:lang/books/:isbn
output:
/about/en/books/123456
/about/en/books/123456
""
{}
{"lang":["en"],"isbn":["123456"]}
/about/:lang/books/:isbn
input:
/about/en/books?isbn=123456&author=Alice&isbn=987654
/about/:lang/books
output:
/about/en/books?isbn=123456&author=Alice
/about/en/books
isbn=123456&author=Alice
{"isbn":["123456", "987654"],"author":["Alice"]}
{"lang":["en"]}
/about/:lang/books?author=?&isbn=?
input:
/other/path
/about/:lang/books
, /docs/:section
output:
/other/path
/other/path
""
{}
{}
/other/path
input:
-path /docs/quickstart/linux
-pattern /docs/:section/*
output:
/docs/quickstart/linux
/docs/quickstart/linux
""
{}
{"quickstart":["linux"]}
/docs/:section/*