@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.amd.js
CHANGED
|
@@ -6215,6 +6215,33 @@ define((function () { 'use strict';
|
|
|
6215
6215
|
});
|
|
6216
6216
|
return formData;
|
|
6217
6217
|
}
|
|
6218
|
+
/**
|
|
6219
|
+
* 将链接转为URL对象,自动补充URL的protocol或者origin
|
|
6220
|
+
* @param text 需要转换的链接字符串
|
|
6221
|
+
* @example
|
|
6222
|
+
* Utils.toUrl("//www.baidu.com/s?word=666");
|
|
6223
|
+
* Utils.toUrl("/s?word=666");
|
|
6224
|
+
*/
|
|
6225
|
+
toUrl(text) {
|
|
6226
|
+
if (typeof text !== "string") {
|
|
6227
|
+
throw new TypeError("toUrl: text must be string");
|
|
6228
|
+
}
|
|
6229
|
+
text = text.trim();
|
|
6230
|
+
if (text === "") {
|
|
6231
|
+
throw new TypeError("toUrl: text must not be empty");
|
|
6232
|
+
}
|
|
6233
|
+
if (text.startsWith("//")) {
|
|
6234
|
+
/* //www.baidu.com/xxxxxxx */
|
|
6235
|
+
/* 没有protocol,加上 */
|
|
6236
|
+
text = UtilsCore.globalThis.location.protocol + text;
|
|
6237
|
+
}
|
|
6238
|
+
else if (text.startsWith("/")) {
|
|
6239
|
+
/* /xxx/info?xxx=xxx */
|
|
6240
|
+
/* 没有Origin,加上 */
|
|
6241
|
+
text = UtilsCore.globalThis.location.origin + text;
|
|
6242
|
+
}
|
|
6243
|
+
return new URL(text);
|
|
6244
|
+
}
|
|
6218
6245
|
/**
|
|
6219
6246
|
* 生成uuid
|
|
6220
6247
|
* @example
|