@hylid/custom-jsapi 0.0.90011373228-dev.9 → 0.0.90011451928-dev.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.
@@ -9,6 +9,7 @@ var __assign = this && this.__assign || function () {
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
11
  import { stringify } from 'qs-es5';
12
+ import { removeEmptyKeys } from 'src/utils/removeEmptyKeys';
12
13
  export var getCallAppLink = function getCallAppLink(opt) {
13
14
  var _a = opt || {},
14
15
  appId = _a.appId,
@@ -33,5 +34,17 @@ export var getCallAppLink = function getCallAppLink(opt) {
33
34
  var extendedInfo = {
34
35
  query: stringify(params)
35
36
  };
36
- return "https://link.dana.id/miniprogram?params=[appId=".concat(appId, "]&destinationPath=").concat(destinationPath, "&extendedInfo=").concat(encodeURIComponent(JSON.stringify(extendedInfo)));
37
+ var url = new URL('https://link.dana.id/miniprogram?params=');
38
+ if (appId) {
39
+ url.searchParams.set('params', "[appId=".concat(appId, "]"));
40
+ }
41
+ if (destinationPath) {
42
+ url.searchParams.set('destinationPath', destinationPath);
43
+ }
44
+ if (extendedInfo && Object.keys(removeEmptyKeys(extendedInfo)).length > 0) {
45
+ url.searchParams.set('extendedInfo', JSON.stringify({
46
+ query: new URLSearchParams(removeEmptyKeys(extendedInfo)).toString()
47
+ }));
48
+ }
49
+ return url.toString();
37
50
  };
@@ -36,5 +36,5 @@ export var getCallAppLink = function getCallAppLink(opt) {
36
36
  });
37
37
  }
38
38
  var link = 'mini://platformapi/startapp?' + stringify(params);
39
- return 'hipay://alipaymini/openUrl?url' + encodeURIComponent(link);
39
+ return 'hipay://alipaymini/openUrl?url=' + encodeURIComponent(link);
40
40
  };
@@ -0,0 +1 @@
1
+ export declare const removeEmptyKeys: <T extends Record<string, string | undefined>>(v?: T | undefined) => Record<string, string>;
@@ -0,0 +1,13 @@
1
+ export var removeEmptyKeys = function removeEmptyKeys(v) {
2
+ if (!v) {
3
+ return {};
4
+ }
5
+ var result = {};
6
+ Object.keys(v).forEach(function (key) {
7
+ var value = v[key];
8
+ if (value) {
9
+ result[key] = value;
10
+ }
11
+ });
12
+ return result;
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hylid/custom-jsapi",
3
- "version": "0.0.90011373228-dev.9",
3
+ "version": "0.0.90011451928-dev.1",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib"
@@ -9,9 +9,9 @@
9
9
  "access": "public"
10
10
  },
11
11
  "dependencies": {
12
- "@hylid/call": "^0.0.90011373228-dev.9",
13
- "@hylid/env": "^0.0.90011373228-dev.9",
14
- "@hylid/types": "^0.0.90011373228-dev.9",
12
+ "@hylid/call": "^0.0.90011451928-dev.1",
13
+ "@hylid/env": "^0.0.90011451928-dev.1",
14
+ "@hylid/types": "^0.0.90011451928-dev.1",
15
15
  "qs-es5": "^6.8.4"
16
16
  },
17
17
  "license": "MIT",