@fonixtree/magic-design 2.0.68 → 2.0.70

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.
@@ -287,14 +287,19 @@ var getCoupon = function getCoupon(couponId) {
287
287
  };
288
288
 
289
289
  function isUrl(string) {
290
- var pattern = new RegExp('^(https?:\\/\\/)?' + // 协议
291
- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // 域名
292
- '((\\d{1,3}\\.){3}\\d{1,3}))' + // 或者 IP (v4) 地址
293
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // 端口和路径
294
- '(\\?[;&a-z\\d%_.~+=-]*)?' + // 查询字符串
295
- '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
296
-
297
- return !!pattern.test(string);
290
+ // var pattern = new RegExp('^(https?:\\/\\/)?' + // 协议
291
+ // '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // 域名
292
+ // '((\\d{1,3}\\.){3}\\d{1,3}))' + // 或者 IP (v4) 地址
293
+ // '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // 端口和路径
294
+ // '(\\?[;&a-z\\d%_.~+=-]*)?' + // 查询字符串
295
+ // '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
296
+ // return !!pattern.test(string);
297
+ try {
298
+ new URL(string);
299
+ return true;
300
+ } catch (_) {
301
+ return false;
302
+ }
298
303
  }
299
304
 
300
305
  var clickUrl = function clickUrl(url) {
@@ -358,12 +363,12 @@ var clickUrl = function clickUrl(url) {
358
363
 
359
364
  if (isUrl(link)) {
360
365
  if (!link.includes(window.location.host)) {
361
- // 跳转外链 需要把token带上
366
+ // 跳转外链 需要把userToken带上
362
367
  if (link.includes('?')) {
363
- var a = link + "&token=" + (localStorage.getItem('h5Token') || '');
368
+ var a = link + "&userToken=" + (localStorage.getItem('h5Token') || '');
364
369
  window.open(a);
365
370
  } else {
366
- var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
371
+ var a = link + "?userToken=" + (localStorage.getItem('h5Token') || '');
367
372
  window.open(a);
368
373
  }
369
374
  }
@@ -287,14 +287,19 @@ var getCoupon = function getCoupon(couponId) {
287
287
  };
288
288
 
289
289
  function isUrl(string) {
290
- var pattern = new RegExp('^(https?:\\/\\/)?' + // 协议
291
- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // 域名
292
- '((\\d{1,3}\\.){3}\\d{1,3}))' + // 或者 IP (v4) 地址
293
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // 端口和路径
294
- '(\\?[;&a-z\\d%_.~+=-]*)?' + // 查询字符串
295
- '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
296
-
297
- return !!pattern.test(string);
290
+ // var pattern = new RegExp('^(https?:\\/\\/)?' + // 协议
291
+ // '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // 域名
292
+ // '((\\d{1,3}\\.){3}\\d{1,3}))' + // 或者 IP (v4) 地址
293
+ // '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // 端口和路径
294
+ // '(\\?[;&a-z\\d%_.~+=-]*)?' + // 查询字符串
295
+ // '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
296
+ // return !!pattern.test(string);
297
+ try {
298
+ new URL(string);
299
+ return true;
300
+ } catch (_) {
301
+ return false;
302
+ }
298
303
  }
299
304
 
300
305
  var clickUrl = function clickUrl(url) {
@@ -358,12 +363,12 @@ var clickUrl = function clickUrl(url) {
358
363
 
359
364
  if (isUrl(link)) {
360
365
  if (!link.includes(window.location.host)) {
361
- // 跳转外链 需要把token带上
366
+ // 跳转外链 需要把userToken带上
362
367
  if (link.includes('?')) {
363
- var a = link + "&token=" + (localStorage.getItem('h5Token') || '');
368
+ var a = link + "&userToken=" + (localStorage.getItem('h5Token') || '');
364
369
  window.open(a);
365
370
  } else {
366
- var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
371
+ var a = link + "?userToken=" + (localStorage.getItem('h5Token') || '');
367
372
  window.open(a);
368
373
  }
369
374
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "2.0.68",
4
+ "version": "2.0.70",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",