url-tag
compare a url string or object to a url pattern spec to find matches
Last updated 7 years ago by tphummel .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install url-tag 
SYNC missed versions from official npm registry.

url-tag

compare a url string or object to a url pattern spec to find matches.

Build Status
NPM browser support

install

npm install url-tag

test

npm test

usage

var ut, spec, url, isMatch;

ut = require("url-tag");

spec = {
  pathname: {
    "/form-page": true
  },
  query: {
    "appId": "123"
  }
}

url = "http://www.domain.com/form-page?appId=123";

isMatch = ut(url, spec);

// prints "true"
console.log(isMatch);

notes

spec.pathname can have multiple pathname keys. the pathname of the parsed url must match ANY of the supplied keys to be satisfied. currently, the value for the pathname key carries no significance, though it should be truthy.

spec.query can have multiple key-value pairs. ALL pairs must be present and equal to be satisfied.

todo

  • allow optional mode in which matching ANY of the supplied query pairs will satisfy the matcher.

Current Tags

  • 0.3.0                                ...           latest (7 years ago)

6 Versions

  • 0.3.0                                ...           7 years ago
  • 0.2.2                                ...           7 years ago
  • 0.2.1                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |