@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/src/Utils.d.ts
CHANGED
|
@@ -1745,6 +1745,14 @@ declare class Utils {
|
|
|
1745
1745
|
toFormData(data: {
|
|
1746
1746
|
[key: string]: string | Blob | File | number;
|
|
1747
1747
|
}, isEncode?: boolean, valueAutoParseToStr?: boolean): FormData;
|
|
1748
|
+
/**
|
|
1749
|
+
* 将链接转为URL对象,自动补充URL的protocol或者origin
|
|
1750
|
+
* @param text 需要转换的链接字符串
|
|
1751
|
+
* @example
|
|
1752
|
+
* Utils.toUrl("//www.baidu.com/s?word=666");
|
|
1753
|
+
* Utils.toUrl("/s?word=666");
|
|
1754
|
+
*/
|
|
1755
|
+
toUrl(text: string): URL;
|
|
1748
1756
|
/**
|
|
1749
1757
|
* 生成uuid
|
|
1750
1758
|
* @example
|
package/dist/src/VueObject.d.ts
CHANGED
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -4869,6 +4869,32 @@ class Utils {
|
|
|
4869
4869
|
});
|
|
4870
4870
|
return formData;
|
|
4871
4871
|
}
|
|
4872
|
+
/**
|
|
4873
|
+
* 将链接转为URL对象,自动补充URL的protocol或者origin
|
|
4874
|
+
* @param text 需要转换的链接字符串
|
|
4875
|
+
* @example
|
|
4876
|
+
* Utils.toUrl("//www.baidu.com/s?word=666");
|
|
4877
|
+
* Utils.toUrl("/s?word=666");
|
|
4878
|
+
*/
|
|
4879
|
+
toUrl(text: string) {
|
|
4880
|
+
if (typeof text !== "string") {
|
|
4881
|
+
throw new TypeError("toUrl: text must be string");
|
|
4882
|
+
}
|
|
4883
|
+
text = text.trim();
|
|
4884
|
+
if (text === "") {
|
|
4885
|
+
throw new TypeError("toUrl: text must not be empty");
|
|
4886
|
+
}
|
|
4887
|
+
if (text.startsWith("//")) {
|
|
4888
|
+
/* //www.baidu.com/xxxxxxx */
|
|
4889
|
+
/* 没有protocol,加上 */
|
|
4890
|
+
text = UtilsCore.globalThis.location.protocol + text;
|
|
4891
|
+
} else if (text.startsWith("/")) {
|
|
4892
|
+
/* /xxx/info?xxx=xxx */
|
|
4893
|
+
/* 没有Origin,加上 */
|
|
4894
|
+
text = UtilsCore.globalThis.location.origin + text;
|
|
4895
|
+
}
|
|
4896
|
+
return new URL(text);
|
|
4897
|
+
}
|
|
4872
4898
|
/**
|
|
4873
4899
|
* 生成uuid
|
|
4874
4900
|
* @example
|