Socket
Socket
Sign inDemoInstall

uri-template-lite

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.10 to 0.1.11

14

dist/uri-expand-src.js
/*
* @version 0.1.10
* @date 2014-12-08
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
/**
* @version 0.1.11
* @date 2015-02-09
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/

@@ -12,0 +12,0 @@

@@ -1,2 +0,5 @@

!function(h){function p(a){return encodeURIComponent(a).replace(q,escape)}function r(a,e,l){return a+(e||"&"==l?"=":"")+e}function s(a){return"string"==typeof a}function m(a,e,l){a=a.map(e).filter(s);return a.length&&a.join(l)}function n(a,e){return a.replace(t,function(a,c,h){var d=u[c]||c,k=c&&","==d?encodeURI:p,f=(";"==d||"&"==d)&&r;return(a=m(h.split(","),function(a){var c=a!=(a=a.split("*")[0]),g=!c&&(g=a.split(":"),a=g[0],g[1]),b=e[a];if(null!=b){if("object"==typeof b){if(Array.isArray(b)?b=
m(b,k,c?f?d+a+"=":d:","):(b=m(Object.keys(b),function(a){return k(a)+(c?"=":",")+k(b[a])},c&&(f||"/"==d)?d:","),c&&(f=null)),!b)return}else b=k(g?b.slice(0,g):b);return f?f(a,b,d):b}},d))||""===a?"+"!=c?c+a:a:""})}var q=/[\]\[:\/?#@!$&()*+,;=']/g,u={"":",","+":",","#":",","?":"&"},t=/\{([+#.\/;?&]?)((?:[\w%.]+(\*|:\d)?,?)+)\}/g;h.expand=n;h.Template=function(a){this.expand=n.bind(this,a)}}(this.URI||(this.URI={}));
/*
MIT License
*/
!function(h){function p(a){return encodeURIComponent(a).replace(q,escape)}function r(a,e,l){return a+(e||"&"==l?"=":"")+e}function t(a){return"string"==typeof a}function m(a,e,l){a=a.map(e).filter(t);return a.length&&a.join(l)}function n(a,e){return a.replace(u,function(a,c,h){var d=v[c]||c,k=c&&","==d?encodeURI:p,f=(";"==d||"&"==d)&&r;return(a=m(h.split(","),function(a){var c=a!=(a=a.split("*")[0]),g=!c&&(g=a.split(":"),a=g[0],g[1]),b=e[a];if(null!=b){if("object"==typeof b){if(Array.isArray(b)?b=
m(b,k,c?f?d+a+"=":d:","):(b=m(Object.keys(b),function(a){return k(a)+(c?"=":",")+k(b[a])},c&&(f||"/"==d)?d:","),c&&(f=null)),!b)return}else b=k(g?b.slice(0,g):b);return f?f(a,b,d):b}},d))||""===a?"+"!=c?c+a:a:""})}var q=/[\]\[:\/?#@!$&()*+,;=']/g,v={"":",","+":",","#":",","?":"&"},u=/\{([+#.\/;?&]?)((?:[\w%.]+(\*|:\d)?,?)+)\}/g;h.expand=n;h.Template=function(a){this.expand=n.bind(this,a)}}(this.URI||(this.URI={}));
/*
* @version 0.1.10
* @date 2014-12-08
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
/**
* @version 0.1.11
* @date 2015-02-09
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/

@@ -12,0 +12,0 @@

@@ -0,2 +1,5 @@

/*
MIT License
*/
!function(b){function d(a){this.init(a)}function e(a){return a.replace(k,"\\$&")}var m={"":",","+":",","#":",","?":"&"},k=/[.*+?^=!:${}()|\[\]\/\\]/g,n=new RegExp(/\{([+#.\/;?&]?)((?:[\w%.]+(\*|:\d)?,?)+)\}/g.source+"|.[^{]*?","g");d.prototype={init:function(a){var l=0,f="",d={},b="^"+a.replace(n,function(a,h,b){if(!b)return e(a);var g=m[h]||h,k=";"==g||"&"==g;a=b.split(",").map(function(a){var b="(.*?)",c=a==(a=a.split("*")[0])&&(c=a.split(":"),a=c[0],c[1]);l++;if(c)b="((?:%..|.){1,"+c+"})",d[a]=
{pos:l,len:c};else if(c=d[a])b="(\\"+c.pos+".*?)";f+="t=($["+l+"]||'').split('"+g+"').map(decodeURIComponent);";f+='o["'+a+'"]=t.length>1?t:t[0];';return k?"&"==g?e(a+"=")+b:e(a)+"(?:="+b+")?":b}).join(e(g));return("+"!=h?e(h):"")+a})+"$";this.template=a;this.re=new RegExp(b);this.fn=new Function("$","var t,o={};"+f+"return o")},match:function(a){return(a=this.re.exec(a))&&this.fn(a)}};b.Template=d}(this.URI||(this.URI={}));

@@ -1,4 +0,7 @@

!function(n){function t(a){return encodeURIComponent(a).replace(u,escape)}function v(a,f,d){return a+(f||"&"==d?"=":"")+f}function w(a){return"string"==typeof a}function e(a,f,d){a=a.map(f).filter(w);return a.length&&a.join(d)}function p(a,f){return a.replace(q,function(a,h,l){var c=r[h]||h,g=h&&","==c?encodeURI:t,k=(";"==c||"&"==c)&&v;return(a=e(l.split(","),function(a){var d=a!=(a=a.split("*")[0]),m=!d&&(m=a.split(":"),a=m[0],m[1]),b=f[a];if(null!=b){if("object"==typeof b){if(Array.isArray(b)?b=
e(b,g,d?k?c+a+"=":c:","):(b=e(Object.keys(b),function(a){return g(a)+(d?"=":",")+g(b[a])},d&&(k||"/"==c)?c:","),d&&(k=null)),!b)return}else b=g(m?b.slice(0,m):b);return k?k(a,b,c):b}},c))||""===a?"+"!=h?h+a:a:""})}function s(a){this.init(a);this.expand=p.bind(this,a)}function l(a){return a.replace(x,"\\$&")}var u=/[\]\[:\/?#@!$&()*+,;=']/g,r={"":",","+":",","#":",","?":"&"},x=/[.*+?^=!:${}()|\[\]\/\\]/g,q=/\{([+#.\/;?&]?)((?:[\w%.]+(\*|:\d)?,?)+)\}/g,y=new RegExp(q.source+"|.[^{]*?","g");n.expand=
p;s.prototype={init:function(a){var f=0,d="",h={},e="^"+a.replace(y,function(a,g,k){if(!k)return l(a);var e=r[g]||g,n=";"==e||"&"==e;a=k.split(",").map(function(a){var b="(.*?)",c=a==(a=a.split("*")[0])&&(c=a.split(":"),a=c[0],c[1]);f++;if(c)b="((?:%..|.){1,"+c+"})",h[a]={pos:f,len:c};else if(c=h[a])b="(\\"+c.pos+".*?)";d+="t=($["+f+"]||'').split('"+e+"').map(decodeURIComponent);";d+='o["'+a+'"]=t.length>1?t:t[0];';return n?"&"==e?l(a+"=")+b:l(a)+"(?:="+b+")?":b}).join(l(e));return("+"!=g?l(g):"")+
a})+"$";this.template=a;this.re=new RegExp(e);this.fn=new Function("$","var t,o={};"+d+"return o")},match:function(a){return(a=this.re.exec(a))&&this.fn(a)}};n.Template=s}(this.URI||(this.URI={}));
/*
MIT License
*/
!function(n){function u(a){return encodeURIComponent(a).replace(v,escape)}function w(a,f,d){return a+(f||"&"==d?"=":"")+f}function x(a){return"string"==typeof a}function e(a,f,d){a=a.map(f).filter(x);return a.length&&a.join(d)}function p(a,f){return a.replace(q,function(a,h,l){var c=r[h]||h,g=h&&","==c?encodeURI:u,k=(";"==c||"&"==c)&&w;return(a=e(l.split(","),function(a){var d=a!=(a=a.split("*")[0]),m=!d&&(m=a.split(":"),a=m[0],m[1]),b=f[a];if(null!=b){if("object"==typeof b){if(Array.isArray(b)?b=
e(b,g,d?k?c+a+"=":c:","):(b=e(Object.keys(b),function(a){return g(a)+(d?"=":",")+g(b[a])},d&&(k||"/"==c)?c:","),d&&(k=null)),!b)return}else b=g(m?b.slice(0,m):b);return k?k(a,b,c):b}},c))||""===a?"+"!=h?h+a:a:""})}function t(a){this.init(a);this.expand=p.bind(this,a)}function l(a){return a.replace(y,"\\$&")}var v=/[\]\[:\/?#@!$&()*+,;=']/g,r={"":",","+":",","#":",","?":"&"},y=/[.*+?^=!:${}()|\[\]\/\\]/g,q=/\{([+#.\/;?&]?)((?:[\w%.]+(\*|:\d)?,?)+)\}/g,z=new RegExp(q.source+"|.[^{]*?","g");n.expand=
p;t.prototype={init:function(a){var f=0,d="",h={},e="^"+a.replace(z,function(a,g,k){if(!k)return l(a);var e=r[g]||g,n=";"==e||"&"==e;a=k.split(",").map(function(a){var b="(.*?)",c=a==(a=a.split("*")[0])&&(c=a.split(":"),a=c[0],c[1]);f++;if(c)b="((?:%..|.){1,"+c+"})",h[a]={pos:f,len:c};else if(c=h[a])b="(\\"+c.pos+".*?)";d+="t=($["+f+"]||'').split('"+e+"').map(decodeURIComponent);";d+='o["'+a+'"]=t.length>1?t:t[0];';return n?"&"==e?l(a+"=")+b:l(a)+"(?:="+b+")?":b}).join(l(e));return("+"!=g?l(g):"")+
a})+"$";this.template=a;this.re=new RegExp(e);this.fn=new Function("$","var t,o={};"+d+"return o")},match:function(a){return(a=this.re.exec(a))&&this.fn(a)}};n.Template=t}(this.URI||(this.URI={}));
/*
* @version 0.1.10
* @date 2014-12-08
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
/**
* @version 0.1.11
* @date 2015-02-09
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/

@@ -12,0 +12,0 @@

{
"name": "uri-template-lite",
"version": "0.1.10",
"version": "0.1.11",
"stability": 2,
"license": "MIT",
"author": "Lauri Rooden <lauri@rooden.ee>",
"description": "URI Template [RFC 6570] implementation",
"description": "URI Template [RFC 6570] expansion and extraction",
"keywords": [
"uri",
"url",
"template",
"uri-template",
"rfc6570",

@@ -12,0 +14,0 @@ "litejs"

@@ -8,4 +8,4 @@ [1]: https://secure.travis-ci.org/litejs/uri-template-lite.png

@version 0.1.10
@date 2014-12-08
@version 0.1.11
@date 2015-02-09
@stability 2 - Unstable

@@ -18,6 +18,29 @@

URI Template [RFC 6570][] implementation in JavaScript.
URI Template [RFC 6570][] expansion and extraction.
Usage
-----
```javascript
// Call `expand` directly
var data = {"domain":"example.com", "user":"fred", "query":"mycelium"}
URI.expand("http://{domain}/~{user}/foo{?query,number}", data)
// Returns http://example.com/~fred/foo?query=mycelium
// ..or use `Template` constructor
var data = {"domain":"example.com", "user":"fred", "query":"mycelium", "number": 3}
var template = new URI.Template("http://{domain}/~{user}/foo{?query,number}")
template.expand(data)
// Returns http://example.com/~fred/foo?query=mycelium&number=3
// Extract variables
template.match("http://example.com/~fred/foo?query=mycelium&number=3")
// Returns {"domain":"example.com", "user":"fred", "query":"mycelium", "number": "3"}
template.match("http://other.com/?query=mycelium")
// Returns false
```
Installation

@@ -40,27 +63,3 @@ ------------

Usage
-----
### Simple expand
```javascript
var data = {"domain":"example.com", "user":"fred", "query":"mycelium"}
URI.expand("http://{domain}/~{user}/foo{?query,number}", data)
// http://example.com/~fred/foo?query=mycelium
```
### Using Template constructor
```javascript
var template = new URI.Template("http://{domain}/~{user}/foo{?query,number}")
var data = {"domain":"example.com", "user":"fred", "query":"mycelium", "number": 3}
template.expand(data)
// http://example.com/~fred/foo?query=mycelium&number=3
template.match("http://example.com/~fred/foo?query=mycelium&number=3")
// {"domain":"example.com", "user":"fred", "query":"mycelium", "number": "3"}
template.match("http://other.com/?query=mycelium")
// false
```
About error handling

@@ -99,3 +98,3 @@ --------------------

Copyright (c) 2014 Lauri Rooden &lt;lauri@rooden.ee&gt;
Copyright (c) 2014-2015 Lauri Rooden &lt;lauri@rooden.ee&gt;
[The MIT License](http://lauri.rooden.ee/mit-license.txt)

@@ -102,0 +101,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc