@fonixtree/magic-design 2.0.67 → 2.0.69

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,18 +363,13 @@ var clickUrl = function clickUrl(url) {
358
363
 
359
364
  if (isUrl(link)) {
360
365
  if (!link.includes(window.location.host)) {
361
- // 跳转外链
362
- if (localStorage.getItem('isLogin') === 'Y') {
363
- // 登录情况下 需要把token带上
364
- if (link.includes('?')) {
365
- var a = link + "&token=" + localStorage.getItem('h5Token');
366
- window.open(a);
367
- } else {
368
- var a = link + "?token=" + localStorage.getItem('h5Token');
369
- window.open(a);
370
- }
366
+ // 跳转外链 需要把token带上
367
+ if (link.includes('?')) {
368
+ var a = link + "&token=" + (localStorage.getItem('h5Token') || '');
369
+ window.open(a);
371
370
  } else {
372
- window.open(link);
371
+ var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
372
+ window.open(a);
373
373
  }
374
374
  }
375
375
  } else {
@@ -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,18 +363,13 @@ var clickUrl = function clickUrl(url) {
358
363
 
359
364
  if (isUrl(link)) {
360
365
  if (!link.includes(window.location.host)) {
361
- // 跳转外链
362
- if (localStorage.getItem('isLogin') === 'Y') {
363
- // 登录情况下 需要把token带上
364
- if (link.includes('?')) {
365
- var a = link + "&token=" + localStorage.getItem('h5Token');
366
- window.open(a);
367
- } else {
368
- var a = link + "?token=" + localStorage.getItem('h5Token');
369
- window.open(a);
370
- }
366
+ // 跳转外链 需要把token带上
367
+ if (link.includes('?')) {
368
+ var a = link + "&token=" + (localStorage.getItem('h5Token') || '');
369
+ window.open(a);
371
370
  } else {
372
- window.open(link);
371
+ var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
372
+ window.open(a);
373
373
  }
374
374
  }
375
375
  } else {
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.67",
4
+ "version": "2.0.69",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",