Skip to content

Commit 5ba3871

Browse files
committed
chore: v0.3.1
1 parent 5e8f881 commit 5ba3871

File tree

5 files changed

+183
-7
lines changed

5 files changed

+183
-7
lines changed

CHANGELOG.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,167 @@
1+
<a name="0.3.1"></a>
2+
## 0.3.1 (2015-09-04)
3+
4+
5+
### Bug Fixes
6+
7+
* better building and matching of query params ([5e8f881](https://github.com/troch/path-parser/commit/5e8f881))
8+
9+
10+
11+
<a name="0.3.0"></a>
12+
# 0.3.0 (2015-09-03)
13+
14+
15+
### Bug Fixes
16+
17+
* build a path without all query parameters ([208fd8a](https://github.com/troch/path-parser/commit/208fd8a))
18+
19+
### Features
20+
21+
* build paths without search part ([c9973be](https://github.com/troch/path-parser/commit/c9973be))
22+
23+
24+
### BREAKING CHANGES
25+
26+
* .build() now takes an options object as a second parameter
27+
Issue router5/router5#19
28+
29+
30+
31+
<a name="0.2.4"></a>
32+
## 0.2.4 (2015-09-01)
33+
34+
35+
### Features
36+
37+
* allow optional trailing slash for '/' ([570a0c4](https://github.com/troch/path-parser/commit/570a0c4))
38+
39+
40+
41+
<a name="0.2.3"></a>
42+
## 0.2.3 (2015-08-20)
43+
44+
45+
### Bug Fixes
46+
47+
* better escape regular expression special chars so built source matches regexp so ([21d30b7](https://github.com/troch/path-parser/commit/21d30b7))
48+
49+
50+
51+
<a name="0.2.2"></a>
52+
## 0.2.2 (2015-08-19)
53+
54+
55+
### Bug Fixes
56+
57+
* escape special characters properly in regular expressions ([f573957](https://github.com/troch/path-parser/commit/f573957))
58+
59+
60+
61+
<a name="0.2.1"></a>
62+
## 0.2.1 (2015-08-19)
63+
64+
65+
### Bug Fixes
66+
67+
* don't apply optional trailing slashes on paths === / ([36e0180](https://github.com/troch/path-parser/commit/36e0180))
68+
69+
70+
71+
<a name="0.2.0"></a>
72+
# 0.2.0 (2015-08-19)
73+
74+
75+
### Features
76+
77+
* support optional trailing slashes ([6785886](https://github.com/troch/path-parser/commit/6785886))
78+
79+
80+
81+
<a name="0.1.1"></a>
82+
## 0.1.1 (2015-07-22)
83+
84+
85+
86+
87+
<a name="0.1.0"></a>
88+
# 0.1.0 (2015-07-06)
89+
90+
91+
### Features
92+
93+
* add matrix and url parameter constraints ([a567ba1](https://github.com/troch/path-parser/commit/a567ba1))
94+
95+
96+
97+
<a name="0.0.7"></a>
98+
## 0.0.7 (2015-07-01)
99+
100+
101+
### Features
102+
103+
* support matrix parameters ([0451290](https://github.com/troch/path-parser/commit/0451290))
104+
105+
106+
107+
<a name="0.0.6"></a>
108+
## 0.0.6 (2015-06-30)
109+
110+
111+
112+
113+
<a name="0.0.5"></a>
114+
## 0.0.5 (2015-06-30)
115+
116+
117+
118+
119+
<a name="0.0.4"></a>
120+
## 0.0.4 (2015-06-28)
121+
122+
123+
### Bug Fixes
124+
125+
* fix bug when multiple query params ([880bae0](https://github.com/troch/path-parser/commit/880bae0))
126+
127+
### Features
128+
129+
* improve tokenisation and tests ([5b9e1fe](https://github.com/troch/path-parser/commit/5b9e1fe))
130+
131+
132+
133+
<a name="0.0.3"></a>
134+
## 0.0.3 (2015-06-26)
135+
136+
137+
### Bug Fixes
138+
139+
* fix path building with splats ([7bd7d74](https://github.com/troch/path-parser/commit/7bd7d74))
140+
141+
142+
143+
<a name="0.0.2"></a>
144+
## 0.0.2 (2015-06-25)
145+
146+
147+
### Features
148+
149+
* add splat support with query params ([96bcd6d](https://github.com/troch/path-parser/commit/96bcd6d))
150+
151+
152+
153+
<a name="0.0.1"></a>
154+
## 0.0.1 (2015-06-25)
155+
156+
157+
### Features
158+
159+
* add spat param flag ([b77174a](https://github.com/troch/path-parser/commit/b77174a))
160+
* add support for query parameters ([4ee86cf](https://github.com/troch/path-parser/commit/4ee86cf))
161+
* add support for splats ([e346bbf](https://github.com/troch/path-parser/commit/e346bbf))
162+
163+
164+
1165
<a name="0.3.0"></a>
2166
# 0.3.0 (2015-09-03)
3167

dist/amd/path-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ define(['exports', 'module'], function (exports, module) {
8989
return source.replace(/\\\/$/, '') + '(?:\\/)?';
9090
};
9191

92+
var isSerialisable = function isSerialisable(val) {
93+
return val !== undefined && val !== null && val !== '';
94+
};
95+
9296
var Path = (function () {
9397
function Path(path) {
9498
_classCallCheck(this, Path);
@@ -173,7 +177,7 @@ define(['exports', 'module'], function (exports, module) {
173177
var queryParams = path.split('?')[1].split('&').map(function (_) {
174178
return _.split('=');
175179
}).reduce(function (obj, m) {
176-
obj[m[0]] = m[1];
180+
obj[m[0]] = m[1] === undefined ? '' : m[1];
177181
return obj;
178182
}, {});
179183

@@ -236,7 +240,7 @@ define(['exports', 'module'], function (exports, module) {
236240
var searchPart = this.queryParams.filter(function (p) {
237241
return Object.keys(params).indexOf(p) !== -1;
238242
}).map(function (p) {
239-
return p + '=' + params[p];
243+
return p + (isSerialisable(params[p]) ? '=' + params[p] : '');
240244
}).join('&');
241245

242246
return base + (searchPart ? '?' + searchPart : '');

dist/commonjs/path-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ var optTrailingSlash = function optTrailingSlash(source, trailingSlash) {
9292
return source.replace(/\\\/$/, '') + '(?:\\/)?';
9393
};
9494

95+
var isSerialisable = function isSerialisable(val) {
96+
return val !== undefined && val !== null && val !== '';
97+
};
98+
9599
var Path = (function () {
96100
function Path(path) {
97101
_classCallCheck(this, Path);
@@ -176,7 +180,7 @@ var Path = (function () {
176180
var queryParams = path.split('?')[1].split('&').map(function (_) {
177181
return _.split('=');
178182
}).reduce(function (obj, m) {
179-
obj[m[0]] = m[1];
183+
obj[m[0]] = m[1] === undefined ? '' : m[1];
180184
return obj;
181185
}, {});
182186

@@ -239,7 +243,7 @@ var Path = (function () {
239243
var searchPart = this.queryParams.filter(function (p) {
240244
return Object.keys(params).indexOf(p) !== -1;
241245
}).map(function (p) {
242-
return p + '=' + params[p];
246+
return p + (isSerialisable(params[p]) ? '=' + params[p] : '');
243247
}).join('&');
244248

245249
return base + (searchPart ? '?' + searchPart : '');

dist/umd/path-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
return source.replace(/\\\/$/, '') + '(?:\\/)?';
102102
};
103103

104+
var isSerialisable = function isSerialisable(val) {
105+
return val !== undefined && val !== null && val !== '';
106+
};
107+
104108
var Path = (function () {
105109
function Path(path) {
106110
_classCallCheck(this, Path);
@@ -185,7 +189,7 @@
185189
var queryParams = path.split('?')[1].split('&').map(function (_) {
186190
return _.split('=');
187191
}).reduce(function (obj, m) {
188-
obj[m[0]] = m[1];
192+
obj[m[0]] = m[1] === undefined ? '' : m[1];
189193
return obj;
190194
}, {});
191195

@@ -248,7 +252,7 @@
248252
var searchPart = this.queryParams.filter(function (p) {
249253
return Object.keys(params).indexOf(p) !== -1;
250254
}).map(function (p) {
251-
return p + '=' + params[p];
255+
return p + (isSerialisable(params[p]) ? '=' + params[p] : '');
252256
}).join('&');
253257

254258
return base + (searchPart ? '?' + searchPart : '');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "path-parser",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "A small utility to parse, match and generate paths",
55
"main": "dist/commonjs/path-parser.js",
66
"scripts": {

0 commit comments

Comments
 (0)