@ray-js/library 0.6.20 → 0.6.22-beta-1
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/url/format.js +0 -6
- package/lib/url/params.js +8 -7
- package/lib/url/parse.js +27 -8
- package/package.json +3 -3
package/lib/url/format.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import "core-js/modules/es.regexp.exec.js";
|
|
3
3
|
import "core-js/modules/es.string.search.js";
|
|
4
|
-
import "core-js/modules/es.array.slice.js";
|
|
5
4
|
import "core-js/modules/es.array.concat.js";
|
|
6
5
|
import queryStringify from './queryStringify';
|
|
7
6
|
import searchParse from './searchParse';
|
|
@@ -17,10 +16,5 @@ export default function format(attrs) {
|
|
|
17
16
|
_attrs$search = attrs.search,
|
|
18
17
|
search = _attrs$search === void 0 ? '' : _attrs$search;
|
|
19
18
|
var searchQuery = searchParse(search);
|
|
20
|
-
|
|
21
|
-
if (hash) {
|
|
22
|
-
query.____h_a_s_h____ = hash.slice(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
19
|
return "".concat(origin).concat(pathname).concat(queryStringify(_objectSpread(_objectSpread({}, query), searchQuery))).concat(hash);
|
|
26
20
|
}
|
package/lib/url/params.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["query"];
|
|
1
4
|
import "core-js/modules/es.array.concat.js";
|
|
2
5
|
import merge from 'merge';
|
|
3
6
|
import parse from './parse';
|
|
4
|
-
import
|
|
7
|
+
import format from './format';
|
|
5
8
|
/**
|
|
6
9
|
* 调整页面地址的 query
|
|
7
10
|
* @param url - url 地址
|
|
@@ -12,15 +15,13 @@ import queryStringify from './queryStringify';
|
|
|
12
15
|
export default function params(url) {
|
|
13
16
|
var _parse = parse(url),
|
|
14
17
|
query = _parse.query,
|
|
15
|
-
|
|
16
|
-
origin = _parse.origin,
|
|
17
|
-
hash = _parse.hash;
|
|
18
|
+
rest = _objectWithoutProperties(_parse, _excluded);
|
|
18
19
|
|
|
19
20
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
20
21
|
args[_key - 1] = arguments[_key];
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
return format(_objectSpread({
|
|
25
|
+
query: merge.apply(void 0, [query].concat(args))
|
|
26
|
+
}, rest));
|
|
26
27
|
}
|
package/lib/url/parse.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["pathname"]
|
|
3
|
+
var _excluded = ["pathname"],
|
|
4
|
+
_excluded2 = ["____h_a_s_h____"];
|
|
4
5
|
import "core-js/modules/es.regexp.exec.js";
|
|
5
6
|
import "core-js/modules/es.object.to-string.js";
|
|
6
7
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
@@ -8,6 +9,7 @@ import "core-js/modules/es.object.keys.js";
|
|
|
8
9
|
import "core-js/modules/es.string.search.js";
|
|
9
10
|
import { NamedRegexp } from '../regexp';
|
|
10
11
|
import searchParse from './searchParse';
|
|
12
|
+
import format from './format';
|
|
11
13
|
var URL_REGEX = new NamedRegexp({
|
|
12
14
|
regex: /(((?:http|https):)?(?:\/\/)?(([^:/?#]*)(?::(\d+))?))?([^?#]+)?(\?[^#]*)?(#.*)?/,
|
|
13
15
|
groups: ['origin', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash']
|
|
@@ -25,18 +27,35 @@ export default function parse(href) {
|
|
|
25
27
|
groups[key] = '';
|
|
26
28
|
}
|
|
27
29
|
});
|
|
28
|
-
var query = {};
|
|
29
|
-
|
|
30
|
-
if (groups.search) {
|
|
31
|
-
query = searchParse(groups.search);
|
|
32
|
-
}
|
|
33
30
|
|
|
34
31
|
var pathname = groups.pathname,
|
|
35
32
|
restGroups = _objectWithoutProperties(groups, _excluded);
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
query:
|
|
34
|
+
var res = _objectSpread({
|
|
35
|
+
query: {},
|
|
39
36
|
href: href,
|
|
40
37
|
pathname: pathname ? pathname : '/'
|
|
41
38
|
}, restGroups);
|
|
39
|
+
|
|
40
|
+
if (groups.search) {
|
|
41
|
+
// 小程序不能传递hash,用query.____h_a_s_h____传递
|
|
42
|
+
// 回显恢复____h_a_s_h____ ====> hash
|
|
43
|
+
// 从query中接出hash值
|
|
44
|
+
var _searchParse = searchParse(groups.search),
|
|
45
|
+
____h_a_s_h____ = _searchParse.____h_a_s_h____,
|
|
46
|
+
query = _objectWithoutProperties(_searchParse, _excluded2);
|
|
47
|
+
|
|
48
|
+
res.query = query;
|
|
49
|
+
|
|
50
|
+
if (____h_a_s_h____) {
|
|
51
|
+
// 剔除 ____h_a_s_h____
|
|
52
|
+
res.hash = res.hash || "#".concat(____h_a_s_h____);
|
|
53
|
+
res.search = format({
|
|
54
|
+
query: query
|
|
55
|
+
});
|
|
56
|
+
res.href = format(res);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return res;
|
|
42
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/library",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.22-beta-1",
|
|
4
4
|
"description": "Ray library for browser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ray"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"merge": "^2.1.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ray-js/cli": "^0.6.
|
|
26
|
+
"@ray-js/cli": "^0.6.22-beta-1"
|
|
27
27
|
},
|
|
28
28
|
"maintainers": [
|
|
29
29
|
{
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"email": "tuyafe@tuya.com"
|
|
32
32
|
}
|
|
33
33
|
],
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "2e905a1820d0adfc0a6ca8cf3ecf1f3a584a0d44",
|
|
35
35
|
"repository": {}
|
|
36
36
|
}
|