@whitesev/utils 1.5.3 → 1.5.4
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/dist/index.amd.js +27 -0
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +27 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +27 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +27 -0
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +27 -0
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +27 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Utils.d.ts +8 -0
- package/dist/src/VueObject.d.ts +3 -0
- package/package.json +1 -1
- package/src/Utils.ts +26 -0
- package/src/VueObject.ts +4 -0
package/dist/index.iife.js
CHANGED
|
@@ -6216,6 +6216,33 @@ var Utils = (function () {
|
|
|
6216
6216
|
});
|
|
6217
6217
|
return formData;
|
|
6218
6218
|
}
|
|
6219
|
+
/**
|
|
6220
|
+
* 将链接转为URL对象,自动补充URL的protocol或者origin
|
|
6221
|
+
* @param text 需要转换的链接字符串
|
|
6222
|
+
* @example
|
|
6223
|
+
* Utils.toUrl("//www.baidu.com/s?word=666");
|
|
6224
|
+
* Utils.toUrl("/s?word=666");
|
|
6225
|
+
*/
|
|
6226
|
+
toUrl(text) {
|
|
6227
|
+
if (typeof text !== "string") {
|
|
6228
|
+
throw new TypeError("toUrl: text must be string");
|
|
6229
|
+
}
|
|
6230
|
+
text = text.trim();
|
|
6231
|
+
if (text === "") {
|
|
6232
|
+
throw new TypeError("toUrl: text must not be empty");
|
|
6233
|
+
}
|
|
6234
|
+
if (text.startsWith("//")) {
|
|
6235
|
+
/* //www.baidu.com/xxxxxxx */
|
|
6236
|
+
/* 没有protocol,加上 */
|
|
6237
|
+
text = UtilsCore.globalThis.location.protocol + text;
|
|
6238
|
+
}
|
|
6239
|
+
else if (text.startsWith("/")) {
|
|
6240
|
+
/* /xxx/info?xxx=xxx */
|
|
6241
|
+
/* 没有Origin,加上 */
|
|
6242
|
+
text = UtilsCore.globalThis.location.origin + text;
|
|
6243
|
+
}
|
|
6244
|
+
return new URL(text);
|
|
6245
|
+
}
|
|
6219
6246
|
/**
|
|
6220
6247
|
* 生成uuid
|
|
6221
6248
|
* @example
|