@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.
- package/es/utils/coreUtil.js +19 -19
- package/lib/utils/coreUtil.js +19 -19
- package/package.json +1 -1
package/es/utils/coreUtil.js
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
371
|
+
var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
|
|
372
|
+
window.open(a);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
} else {
|
package/lib/utils/coreUtil.js
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
371
|
+
var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
|
|
372
|
+
window.open(a);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
} else {
|