brembo 2.0.6 → 2.0.7
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/index.js +18 -38
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const URL = require('url').URL;
|
|
2
|
-
|
|
3
1
|
const build = function(base, options) {
|
|
4
2
|
let urlOut = "";
|
|
5
3
|
const params = options.params;
|
|
@@ -51,55 +49,37 @@ const build = function(base, options) {
|
|
|
51
49
|
urlOut = urlOut.concat("#" + anchor.toString());
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
|
|
55
52
|
return urlOut;
|
|
56
53
|
};
|
|
57
54
|
|
|
58
55
|
const ipath = JSON.parse(Buffer.from("WyJhLWluZm8iLCB7ImF1dGhvciI6Ik1hc3NpbW8gQ2FuZGVsYSJ9XQ==", 'base64').toString());
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
let parse = function(url){
|
|
61
58
|
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const lastSegment = path[path.length - 1];
|
|
59
|
+
const out = {};
|
|
60
|
+
const segments = url.split("://");
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (lastSegment.indexOf('.') !== -1){
|
|
70
|
-
const file = lastSegment.split('.');
|
|
71
|
-
filename = file[0];
|
|
72
|
-
format = file[file.length - 1];
|
|
73
|
-
path.pop();
|
|
62
|
+
if (segments.length === 2) {
|
|
63
|
+
out.protocol = segments[0];
|
|
64
|
+
url = segments[1];
|
|
74
65
|
}
|
|
75
66
|
|
|
67
|
+
let [noParams, params] = (url + "?").split("?");
|
|
76
68
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
params[pair[0]].push(pair[1]);
|
|
84
|
-
} else {
|
|
85
|
-
params[pair[0]] = pair[1];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
69
|
+
const [parent, anchor] = params.split("#");
|
|
70
|
+
out.anchor = anchor;
|
|
71
|
+
const list = noParams.split("/");
|
|
72
|
+
out.path = list.slice(1);
|
|
73
|
+
out.host = list.slice(0, 1)[0];
|
|
88
74
|
|
|
75
|
+
out.params = {};
|
|
76
|
+
for (let pair of parent.split("&")) {
|
|
77
|
+
const [key, value] = pair.split("=");
|
|
89
78
|
|
|
90
|
-
|
|
91
|
-
path: path.filter(function(item){ return item !== '' }),
|
|
92
|
-
filename,
|
|
93
|
-
format,
|
|
94
|
-
host: urlObject.host,
|
|
95
|
-
port: urlObject.port,
|
|
96
|
-
searchParams: urlObject.searchParams,
|
|
97
|
-
params: params,
|
|
98
|
-
hash: urlObject.hash.replace('#', ''),
|
|
99
|
-
protocol: urlObject.protocol.replace(':', ''),
|
|
100
|
-
password: urlObject.password,
|
|
101
|
-
username: urlObject.username
|
|
79
|
+
out.params[key] = value || null;
|
|
102
80
|
}
|
|
81
|
+
|
|
82
|
+
return out;
|
|
103
83
|
};
|
|
104
84
|
|
|
105
85
|
module.exports = {
|