@builder.io/sdk 2.2.7-0 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarnrc.yml +1 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.browser.js +58 -79
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +58 -79
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +58 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +58 -79
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/builder.class.d.ts +1 -0
- package/dist/src/builder.class.js +57 -78
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.js +136 -0
- package/dist/src/builder.class.test.js.map +1 -1
- package/dist/src/classes/promise.class.js +154 -150
- package/dist/src/classes/query-string.class.js +74 -73
- package/dist/src/classes/query-string.class.test.js +20 -20
- package/dist/src/functions/assign.function.js +19 -19
- package/dist/src/functions/fetch.function.js +75 -97
- package/dist/src/functions/finder.function.js +274 -389
- package/dist/src/functions/get-top-level-domain.js +8 -8
- package/dist/src/functions/next-tick.function.js +23 -26
- package/dist/src/functions/omit.function.js +13 -13
- package/dist/src/functions/server-only-require.function.js +9 -10
- package/dist/src/functions/throttle.function.js +37 -35
- package/dist/src/functions/to-error.js +6 -5
- package/dist/src/functions/uuid.js +8 -9
- package/dist/src/types/api-version.js +3 -3
- package/dist/src/types/element.js +3 -3
- package/dist/src/url.test.js +118 -222
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTopLevelDomain = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Only gets one level up from hostname
|
|
@@ -7,11 +7,11 @@ exports.getTopLevelDomain = void 0;
|
|
|
7
7
|
* www.example.co.uk -> example.co.uk
|
|
8
8
|
*/
|
|
9
9
|
function getTopLevelDomain(host) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
var parts = host.split('.');
|
|
11
|
+
if (parts.length > 2) {
|
|
12
|
+
return parts.slice(1).join('.');
|
|
13
|
+
}
|
|
14
|
+
return host;
|
|
15
15
|
}
|
|
16
16
|
exports.getTopLevelDomain = getTopLevelDomain;
|
|
17
|
-
//# sourceMappingURL=get-top-level-domain.js.map
|
|
17
|
+
//# sourceMappingURL=get-top-level-domain.js.map
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nextTick = void 0;
|
|
4
|
-
var isSafari =
|
|
5
|
-
|
|
6
|
-
/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);
|
|
4
|
+
var isSafari = typeof window !== 'undefined' &&
|
|
5
|
+
/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);
|
|
7
6
|
var isClient = typeof window !== 'undefined';
|
|
8
7
|
// TODO: queue all of these in a debounceNextTick
|
|
9
8
|
function nextTick(fn) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// tslint:disable-next-line
|
|
29
|
-
element.data = String((called = ++called));
|
|
9
|
+
// if (typeof process !== 'undefined' && process.nextTick) {
|
|
10
|
+
// console.log('process.nextTick?');
|
|
11
|
+
// process.nextTick(fn);
|
|
12
|
+
// return;
|
|
13
|
+
// }
|
|
14
|
+
// FIXME: fix the real safari issue of this randomly not working
|
|
15
|
+
if (!isClient || isSafari || typeof MutationObserver === 'undefined') {
|
|
16
|
+
setTimeout(fn);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
var called = 0;
|
|
20
|
+
var observer = new MutationObserver(function () { return fn(); });
|
|
21
|
+
var element = document.createTextNode('');
|
|
22
|
+
observer.observe(element, {
|
|
23
|
+
characterData: true,
|
|
24
|
+
});
|
|
25
|
+
// tslint:disable-next-line
|
|
26
|
+
element.data = String((called = ++called));
|
|
30
27
|
}
|
|
31
28
|
exports.nextTick = nextTick;
|
|
32
|
-
//# sourceMappingURL=next-tick.function.js.map
|
|
29
|
+
//# sourceMappingURL=next-tick.function.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.omit = void 0;
|
|
4
4
|
function omit(obj) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
var values = [];
|
|
6
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7
|
+
values[_i - 1] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
var newObject = Object.assign({}, obj);
|
|
10
|
+
for (var _a = 0, values_1 = values; _a < values_1.length; _a++) {
|
|
11
|
+
var key = values_1[_a];
|
|
12
|
+
delete newObject[key];
|
|
13
|
+
}
|
|
14
|
+
return newObject;
|
|
15
15
|
}
|
|
16
16
|
exports.omit = omit;
|
|
17
|
-
//# sourceMappingURL=omit.function.js.map
|
|
17
|
+
//# sourceMappingURL=omit.function.js.map
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// Webpack workaround to conditionally require certain external modules
|
|
4
4
|
// only on the server and not bundle them on the client
|
|
5
5
|
var serverOnlyRequire;
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return null;
|
|
13
|
-
};
|
|
7
|
+
// tslint:disable-next-line:no-eval
|
|
8
|
+
serverOnlyRequire = eval('require');
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
// all good
|
|
12
|
+
serverOnlyRequire = (function () { return null; });
|
|
14
13
|
}
|
|
15
14
|
exports.default = serverOnlyRequire;
|
|
16
|
-
//# sourceMappingURL=server-only-require.function.js.map
|
|
15
|
+
//# sourceMappingURL=server-only-require.function.js.map
|
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.throttle = void 0;
|
|
4
4
|
function throttle(func, wait, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var later = function () {
|
|
14
|
-
previous = options.leading === false ? 0 : Date.now();
|
|
15
|
-
timeout = null;
|
|
16
|
-
result = func.apply(context, args);
|
|
17
|
-
if (!timeout) context = args = null;
|
|
18
|
-
};
|
|
19
|
-
return function () {
|
|
20
|
-
var now = Date.now();
|
|
21
|
-
if (!previous && options.leading === false) previous = now;
|
|
22
|
-
var remaining = wait - (now - previous);
|
|
23
|
-
context = this;
|
|
24
|
-
args = arguments;
|
|
25
|
-
if (remaining <= 0 || remaining > wait) {
|
|
26
|
-
if (timeout) {
|
|
27
|
-
clearTimeout(timeout);
|
|
5
|
+
if (options === void 0) { options = {}; }
|
|
6
|
+
var context;
|
|
7
|
+
var args;
|
|
8
|
+
var result;
|
|
9
|
+
var timeout = null;
|
|
10
|
+
var previous = 0;
|
|
11
|
+
var later = function () {
|
|
12
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
28
13
|
timeout = null;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
result = func.apply(context, args);
|
|
15
|
+
if (!timeout)
|
|
16
|
+
context = args = null;
|
|
17
|
+
};
|
|
18
|
+
return function () {
|
|
19
|
+
var now = Date.now();
|
|
20
|
+
if (!previous && options.leading === false)
|
|
21
|
+
previous = now;
|
|
22
|
+
var remaining = wait - (now - previous);
|
|
23
|
+
context = this;
|
|
24
|
+
args = arguments;
|
|
25
|
+
if (remaining <= 0 || remaining > wait) {
|
|
26
|
+
if (timeout) {
|
|
27
|
+
clearTimeout(timeout);
|
|
28
|
+
timeout = null;
|
|
29
|
+
}
|
|
30
|
+
previous = now;
|
|
31
|
+
result = func.apply(context, args);
|
|
32
|
+
if (!timeout)
|
|
33
|
+
context = args = null;
|
|
34
|
+
}
|
|
35
|
+
else if (!timeout && options.trailing !== false) {
|
|
36
|
+
timeout = setTimeout(later, remaining);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
38
40
|
}
|
|
39
41
|
exports.throttle = throttle;
|
|
40
|
-
//# sourceMappingURL=throttle.function.js.map
|
|
42
|
+
//# sourceMappingURL=throttle.function.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toError = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Safe conversion to error type. Intended to be used in catch blocks where the
|
|
@@ -14,8 +14,9 @@ exports.toError = void 0;
|
|
|
14
14
|
* }
|
|
15
15
|
*/
|
|
16
16
|
function toError(err) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (err instanceof Error)
|
|
18
|
+
return err;
|
|
19
|
+
return new Error(String(err));
|
|
19
20
|
}
|
|
20
21
|
exports.toError = toError;
|
|
21
|
-
//# sourceMappingURL=to-error.js.map
|
|
22
|
+
//# sourceMappingURL=to-error.js.map
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uuid = exports.uuidv4 = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @credit https://stackoverflow.com/a/2117523
|
|
6
6
|
*/
|
|
7
7
|
function uuidv4() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
8
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
9
|
+
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
10
|
+
return v.toString(16);
|
|
11
|
+
});
|
|
13
12
|
}
|
|
14
13
|
exports.uuidv4 = uuidv4;
|
|
15
14
|
/**
|
|
16
15
|
* Slightly cleaner and smaller UUIDs
|
|
17
16
|
*/
|
|
18
17
|
function uuid() {
|
|
19
|
-
|
|
18
|
+
return uuidv4().replace(/-/g, '');
|
|
20
19
|
}
|
|
21
20
|
exports.uuid = uuid;
|
|
22
|
-
//# sourceMappingURL=uuid.js.map
|
|
21
|
+
//# sourceMappingURL=uuid.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_API_VERSION = void 0;
|
|
4
4
|
exports.DEFAULT_API_VERSION = 'v3';
|
|
5
|
-
//# sourceMappingURL=api-version.js.map
|
|
5
|
+
//# sourceMappingURL=api-version.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
//# sourceMappingURL=element.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=element.js.map
|
package/dist/src/url.test.js
CHANGED
|
@@ -1,233 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter =
|
|
3
|
-
|
|
4
|
-
function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) {
|
|
6
|
-
return value instanceof P
|
|
7
|
-
? value
|
|
8
|
-
: new P(function (resolve) {
|
|
9
|
-
resolve(value);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
reject(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function rejected(value) {
|
|
21
|
-
try {
|
|
22
|
-
step(generator['throw'](value));
|
|
23
|
-
} catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function step(result) {
|
|
28
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
29
|
-
}
|
|
30
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
9
|
});
|
|
32
|
-
|
|
33
|
-
var __generator =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
label: 0,
|
|
38
|
-
sent: function () {
|
|
39
|
-
if (t[0] & 1) throw t[1];
|
|
40
|
-
return t[1];
|
|
41
|
-
},
|
|
42
|
-
trys: [],
|
|
43
|
-
ops: [],
|
|
44
|
-
},
|
|
45
|
-
f,
|
|
46
|
-
y,
|
|
47
|
-
t,
|
|
48
|
-
g;
|
|
49
|
-
return (
|
|
50
|
-
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
|
|
51
|
-
typeof Symbol === 'function' &&
|
|
52
|
-
(g[Symbol.iterator] = function () {
|
|
53
|
-
return this;
|
|
54
|
-
}),
|
|
55
|
-
g
|
|
56
|
-
);
|
|
57
|
-
function verb(n) {
|
|
58
|
-
return function (v) {
|
|
59
|
-
return step([n, v]);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
62
15
|
function step(op) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
op[0]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
break;
|
|
84
|
-
case 4:
|
|
85
|
-
_.label++;
|
|
86
|
-
return { value: op[1], done: false };
|
|
87
|
-
case 5:
|
|
88
|
-
_.label++;
|
|
89
|
-
y = op[1];
|
|
90
|
-
op = [0];
|
|
91
|
-
continue;
|
|
92
|
-
case 7:
|
|
93
|
-
op = _.ops.pop();
|
|
94
|
-
_.trys.pop();
|
|
95
|
-
continue;
|
|
96
|
-
default:
|
|
97
|
-
if (
|
|
98
|
-
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) &&
|
|
99
|
-
(op[0] === 6 || op[0] === 2)
|
|
100
|
-
) {
|
|
101
|
-
_ = 0;
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
105
|
-
_.label = op[1];
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
109
|
-
_.label = t[1];
|
|
110
|
-
t = op;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
if (t && _.label < t[2]) {
|
|
114
|
-
_.label = t[2];
|
|
115
|
-
_.ops.push(op);
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (t[2]) _.ops.pop();
|
|
119
|
-
_.trys.pop();
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
op = body.call(thisArg, _);
|
|
123
|
-
} catch (e) {
|
|
124
|
-
op = [6, e];
|
|
125
|
-
y = 0;
|
|
126
|
-
} finally {
|
|
127
|
-
f = t = 0;
|
|
128
|
-
}
|
|
129
|
-
if (op[0] & 5) throw op[1];
|
|
130
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
131
36
|
}
|
|
132
|
-
|
|
133
|
-
Object.defineProperty(exports,
|
|
134
|
-
var url_1 = require(
|
|
135
|
-
var url_2 = require(
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var url_1 = require("./url");
|
|
40
|
+
var url_2 = require("url");
|
|
136
41
|
describe('.parse', function () {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
42
|
+
test('can parse a full url', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
expect((0, url_1.parse)('http://example.com/foo/bar?q=1')).toEqual({
|
|
45
|
+
auth: null,
|
|
46
|
+
hash: null,
|
|
47
|
+
host: 'example.com',
|
|
48
|
+
hostname: 'example.com',
|
|
49
|
+
href: 'http://example.com/foo/bar?q=1',
|
|
50
|
+
path: '/foo/bar?q=1',
|
|
51
|
+
pathname: '/foo/bar',
|
|
52
|
+
port: null,
|
|
53
|
+
protocol: 'http:',
|
|
54
|
+
query: 'q=1',
|
|
55
|
+
search: '?q=1',
|
|
56
|
+
slashes: true,
|
|
57
|
+
});
|
|
58
|
+
return [2 /*return*/];
|
|
153
59
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
search: '?q=1',
|
|
173
|
-
slashes: null,
|
|
60
|
+
}); });
|
|
61
|
+
test('can parse a path', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
expect((0, url_1.parse)('/foo/bar?q=1')).toEqual({
|
|
64
|
+
auth: null,
|
|
65
|
+
hash: null,
|
|
66
|
+
host: null,
|
|
67
|
+
hostname: null,
|
|
68
|
+
href: '/foo/bar?q=1',
|
|
69
|
+
path: '/foo/bar?q=1',
|
|
70
|
+
pathname: '/foo/bar',
|
|
71
|
+
port: null,
|
|
72
|
+
protocol: null,
|
|
73
|
+
query: 'q=1',
|
|
74
|
+
search: '?q=1',
|
|
75
|
+
slashes: null,
|
|
76
|
+
});
|
|
77
|
+
return [2 /*return*/];
|
|
174
78
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
search: '?q=1',
|
|
194
|
-
slashes: false,
|
|
79
|
+
}); });
|
|
80
|
+
test('can parse a url that is missing slashes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
expect((0, url_1.parse)('http:example.com/foo/bar?q=1')).toEqual({
|
|
83
|
+
auth: null,
|
|
84
|
+
hash: null,
|
|
85
|
+
host: 'example.com',
|
|
86
|
+
hostname: 'example.com',
|
|
87
|
+
href: 'http://example.com/foo/bar?q=1',
|
|
88
|
+
path: '/foo/bar?q=1',
|
|
89
|
+
pathname: '/foo/bar',
|
|
90
|
+
port: null,
|
|
91
|
+
protocol: 'http:',
|
|
92
|
+
query: 'q=1',
|
|
93
|
+
search: '?q=1',
|
|
94
|
+
slashes: false,
|
|
95
|
+
});
|
|
96
|
+
return [2 /*return*/];
|
|
195
97
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return __generator(this, function (_b) {
|
|
224
|
-
expect(actual[prop]).toEqual(expected[prop]);
|
|
225
|
-
return [2 /*return*/];
|
|
98
|
+
}); });
|
|
99
|
+
describe('behaves the same as the old query function', function () {
|
|
100
|
+
describe.each([{ url: '/foo/bar?a=1&b=2' }, { url: 'http://example.com/foo/bar?a=1&b=2' }])('with url `$url`', function (_a) {
|
|
101
|
+
var url = _a.url;
|
|
102
|
+
var expected = Object.assign({}, (0, url_2.parse)(url));
|
|
103
|
+
var actual = (0, url_1.parse)(url);
|
|
104
|
+
test.each([
|
|
105
|
+
{ prop: 'query' },
|
|
106
|
+
{ prop: 'port' },
|
|
107
|
+
{ prop: 'auth' },
|
|
108
|
+
{ prop: 'hash' },
|
|
109
|
+
{ prop: 'host' },
|
|
110
|
+
{ prop: 'hostname' },
|
|
111
|
+
{ prop: 'href' },
|
|
112
|
+
{ prop: 'path' },
|
|
113
|
+
{ prop: 'pathname' },
|
|
114
|
+
{ prop: 'protocol' },
|
|
115
|
+
{ prop: 'search' },
|
|
116
|
+
{ prop: 'slashes' },
|
|
117
|
+
])('`$prop` is the same', function (_a) {
|
|
118
|
+
var prop = _a.prop;
|
|
119
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
+
return __generator(this, function (_b) {
|
|
121
|
+
expect(actual[prop]).toEqual(expected[prop]);
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
});
|
|
124
|
+
});
|
|
226
125
|
});
|
|
227
|
-
});
|
|
228
126
|
});
|
|
229
|
-
|
|
230
|
-
);
|
|
231
|
-
});
|
|
127
|
+
});
|
|
232
128
|
});
|
|
233
|
-
//# sourceMappingURL=url.test.js.map
|
|
129
|
+
//# sourceMappingURL=url.test.js.map
|