@hylid/env 3.2.6 → 3.3.0-alpha.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/checker/mp.js CHANGED
@@ -20,4 +20,7 @@ export var mpChecker = [{
20
20
  }, {
21
21
  name: CLIENT.DANA,
22
22
  match: [/dana/]
23
+ }, {
24
+ name: CLIENT.TOSSPAY,
25
+ match: [/toss/]
23
26
  }];
package/lib/utils.js CHANGED
@@ -33,7 +33,9 @@ export function notice(text) {
33
33
  console.info("[hylid-env]: ".concat(text));
34
34
  }
35
35
  export function getSettingName() {
36
- var client = (window.location.search.match(/[?&]__app__=([^?&=]+)/) || [])[1];
36
+ var _a;
37
+ var clientMatch = ((_a = window.location.search) === null || _a === void 0 ? void 0 : _a.match(/__app__=([^&]*)/)) || [];
38
+ var client = clientMatch[1];
37
39
  var platform = (window.location.search.match(/[?&]__platform__=([^?&=]+)/) || [])[1];
38
40
  if (client || platform) {
39
41
  localStorage.setItem('__hy_env__', JSON.stringify({
@@ -41,6 +43,13 @@ export function getSettingName() {
41
43
  platform: platform
42
44
  }));
43
45
  }
46
+ // 将 url 上的 __app__ 删除,避免影响分享的链接
47
+ if (clientMatch[1]) {
48
+ var search = window.location.search.replace(new RegExp("".concat(clientMatch[0], "(&)*")), '');
49
+ var hash = window.location.hash || '';
50
+ var newUrl = "".concat(window.location.pathname).concat(search).concat(hash);
51
+ history.replaceState(null, '', newUrl);
52
+ }
44
53
  var cached = localStorage.getItem('__hy_env__');
45
54
  return cached ? JSON.parse(cached) : {};
46
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hylid/env",
3
- "version": "3.2.6",
3
+ "version": "3.3.0-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib"