tough-cookie 4.1.3 → 4.1.4
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/lib/cookie.js +4 -2
- package/lib/validators.js +15 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/cookie.js
CHANGED
|
@@ -1116,7 +1116,8 @@ class CookieJar {
|
|
|
1116
1116
|
}
|
|
1117
1117
|
|
|
1118
1118
|
setCookie(cookie, url, options, cb) {
|
|
1119
|
-
validators.validate(validators.
|
|
1119
|
+
validators.validate(validators.isUrlStringOrObject(url), cb, options);
|
|
1120
|
+
|
|
1120
1121
|
let err;
|
|
1121
1122
|
|
|
1122
1123
|
if (validators.isFunction(url)) {
|
|
@@ -1314,7 +1315,8 @@ class CookieJar {
|
|
|
1314
1315
|
|
|
1315
1316
|
// RFC6365 S5.4
|
|
1316
1317
|
getCookies(url, options, cb) {
|
|
1317
|
-
validators.validate(validators.
|
|
1318
|
+
validators.validate(validators.isUrlStringOrObject(url), cb, url);
|
|
1319
|
+
|
|
1318
1320
|
const context = getCookieContext(url);
|
|
1319
1321
|
if (validators.isFunction(options)) {
|
|
1320
1322
|
cb = options;
|
package/lib/validators.js
CHANGED
|
@@ -28,6 +28,9 @@ SOFTWARE.
|
|
|
28
28
|
"use strict";
|
|
29
29
|
|
|
30
30
|
/* Validation functions copied from check-types package - https://www.npmjs.com/package/check-types */
|
|
31
|
+
|
|
32
|
+
const toString = Object.prototype.toString;
|
|
33
|
+
|
|
31
34
|
function isFunction(data) {
|
|
32
35
|
return typeof data === "function";
|
|
33
36
|
}
|
|
@@ -59,6 +62,17 @@ function isInstanceStrict(data, prototype) {
|
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
function isUrlStringOrObject(data) {
|
|
66
|
+
return (
|
|
67
|
+
isNonEmptyString(data) ||
|
|
68
|
+
(isObject(data) &&
|
|
69
|
+
"hostname" in data &&
|
|
70
|
+
"pathname" in data &&
|
|
71
|
+
"protocol" in data) ||
|
|
72
|
+
isInstanceStrict(data, URL)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
62
76
|
function isInteger(data) {
|
|
63
77
|
return typeof data === "number" && data % 1 === 0;
|
|
64
78
|
}
|
|
@@ -92,4 +106,5 @@ exports.isDate = isDate;
|
|
|
92
106
|
exports.isEmptyString = isEmptyString;
|
|
93
107
|
exports.isString = isString;
|
|
94
108
|
exports.isObject = isObject;
|
|
109
|
+
exports.isUrlStringOrObject = isUrlStringOrObject;
|
|
95
110
|
exports.validate = validate;
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
module.exports = '4.1.
|
|
2
|
+
module.exports = '4.1.4'
|