Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including smurl with all npm packages installed. Try it out:

var smurl = require("smurl")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

smurl v1.2.3

smart partial url matching for nodejs and the browser


smart partial url matching for nodejs and the browser

npm install smurl
// api
// match(actual, expected, [interpreter])

// match on protocol
match('', 'http://') // true
match('', 'https://') // false

// match on path
match('', '/somepath') // true
match('', '/somepath') // false
match('', '/') // true

// match on querystring (order of querystring params does not matter)
match('', '?a=b') // true
match('', '?b=c&a=b') // true
match('', '?b=c&a=b') // true
match('', '?b=c&a=b') // false

// match on hash
match('', '#blah') // true

// match on domain
match('', '') // true
match('', '') // true

// match on domain and path
match('', '') // true

// match on all possible fragments
match('', '') // true

/* customising the behaviour with an interpreter */

// ignore protocol
match('', '', ignoreProtocol) // true
function ignoreProtocol (expectation) {
  delete expectation.protocol
  return expectation

// treat as the user wanting to match on 'homepage'
match('', '', homepages) // true
function homepages (expectation) {
  if ( && !expectation.pathname) expectation.pathname = '/'
  return expectation
npm test


Want to work on this for your day job?

This project was created by the Engineering team at Qubit. As we use open source libraries, we make our projects public where possible.

We’re currently looking to grow our team, so if you’re a JavaScript engineer and keen on ES2016 React+Redux applications and Node micro services, why not get in touch? Work with like minded engineers in an environment that has fantastic perks, including an annual ski trip, yoga, a competitive foosball league, and copious amounts of yogurt.

Find more details on our Engineering site. Don’t have an up to date CV? Just link us your Github profile! Better yet, send us a pull request that improves this project.` Contact GitHub API Training Shop Blog About

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free