ts_routes 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ts_routes/runtime.ts +17 -13
- data/lib/ts_routes/version.rb +1 -1
- data/tslint.json +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83884b340a2d1a221f2b76bccb12806c0700de37
|
4
|
+
data.tar.gz: 469bc903d770a8785026770570dd033dd743de53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edca793080e36504208e99bdc1aa7f67e4098dfa43c9765afb08eba93184d1c0915ec7ce953e0b644da4ad02f13f0c2242b9ba8d0786d5795bab8621805a169e
|
7
|
+
data.tar.gz: 65126dbef060562c1998a6b78433b0f3a474d1b2a96f050b3fe5da1d2719f3a5d1020507c05b65c83f77f121c7253f89a9d0d7b26f748c58024acf5cdeae2ab5
|
data/lib/ts_routes/runtime.ts
CHANGED
@@ -16,18 +16,8 @@ function $buildOptions(options: any, names: string[]): string {
|
|
16
16
|
|
17
17
|
if (key === "anchor") {
|
18
18
|
anchor = `#${$encode(value)}`;
|
19
|
-
} else
|
20
|
-
|
21
|
-
} else if (Array.isArray(value)) {
|
22
|
-
for (const v of value) {
|
23
|
-
const k = `${key}[]`;
|
24
|
-
q.push(`${$encode(k)}=${$encode(v)}`);
|
25
|
-
}
|
26
|
-
} else if($isNotNull(value)) { // i.e. non-null, non-scalar, non-array type
|
27
|
-
for (const k of Object.keys(value)) {
|
28
|
-
const hk = `${key}[${k}]`;
|
29
|
-
q.push(`${$encode(hk)}=${$encode(value[k])}`);
|
30
|
-
}
|
19
|
+
} else {
|
20
|
+
$buildQuery(q, key, value);
|
31
21
|
}
|
32
22
|
}
|
33
23
|
return (q.length > 0 ? "?" + q.join("&") : "") + anchor;
|
@@ -36,6 +26,20 @@ function $buildOptions(options: any, names: string[]): string {
|
|
36
26
|
}
|
37
27
|
}
|
38
28
|
|
29
|
+
function $buildQuery(q: string[], key: string, value: any) {
|
30
|
+
if ($isScalarType(value)) {
|
31
|
+
q.push(`${$encode(key)}=${$encode(value)}`);
|
32
|
+
} else if (Array.isArray(value)) {
|
33
|
+
for (const v of value) {
|
34
|
+
$buildQuery(q, `${key}[]`, v);
|
35
|
+
}
|
36
|
+
} else if ($isNotNull(value)) { // i.e. non-null, non-scalar, non-array type
|
37
|
+
for (const k of Object.keys(value)) {
|
38
|
+
$buildQuery(q, `${key}[${k}]`, value[ k ]);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
39
43
|
function $encode(value: any): string {
|
40
44
|
return encodeURIComponent(value);
|
41
45
|
}
|
@@ -53,5 +57,5 @@ function $isPresent(value: any): boolean {
|
|
53
57
|
}
|
54
58
|
|
55
59
|
function $hasPresentOwnProperty(options: any, key: string): boolean {
|
56
|
-
return options && options.hasOwnProperty(key) && $isPresent(options[key]);
|
60
|
+
return options && options.hasOwnProperty(key) && $isPresent(options[ key ]);
|
57
61
|
}
|
data/lib/ts_routes/version.rb
CHANGED
data/tslint.json
CHANGED