Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
| const assert = require('assert') | |
| module.exports = match | |
| // get url path section from a url | |
| // strip querystrings / hashes | |
| // strip protocol | |
| // strip hostname and port (both ip and route) | |
| // str -> str | |
| function match (route) { | |
| assert.equal(typeof route, 'string') | |
| return route.trim() | |
| .replace(/[\?|#].*$/, '') | |
| .replace(/^(?:https?\:)\/\//, '') | |
| .replace(/^.*?(\/.*)/, '$1') | |
| .replace(/\/$/, '') | |
| } |