diginext-utils 2.1.0 → 2.1.2
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/Checker.d.ts +4 -3
- package/dist/EventDispatcher.d.ts +3 -3
- package/dist/FileUpload.d.ts +3 -3
- package/dist/Slug.d.ts +4 -3
- package/dist/Timer-7b0c4e7c.d.ts +11 -0
- package/dist/Timer.d.ts +1 -4
- package/dist/Validation.d.ts +3 -2
- package/dist/array-dc599632.d.ts +158 -0
- package/dist/array.d.ts +1 -113
- package/dist/browser-8d042ffe.d.ts +22 -0
- package/dist/camera-1a859d72.d.ts +15 -0
- package/dist/color.d.ts +9 -8
- package/dist/console/enableConsole.d.ts +1 -2
- package/dist/console/index.d.ts +2 -11
- package/dist/console/log.d.ts +9 -8
- package/dist/createDir-220e0081.d.ts +13 -0
- package/dist/device/browser.d.ts +1 -5
- package/dist/device/camera.d.ts +1 -7
- package/dist/device/index.d.ts +1 -5
- package/dist/device/os.d.ts +7 -6
- package/dist/enableConsole-ddc24282.d.ts +11 -0
- package/dist/file/createDir.d.ts +1 -5
- package/dist/file/fileMove.d.ts +1 -4
- package/dist/file/findFilesByExt.d.ts +1 -13
- package/dist/file/index.d.ts +6 -4
- package/dist/fileMove-3a09e429.d.ts +13 -0
- package/dist/findFilesByExt-753e91d7.d.ts +24 -0
- package/dist/gameboi/index.d.ts +6 -4
- package/dist/images/index.d.ts +2 -2
- package/dist/images/loadImage.d.ts +3 -1
- package/dist/images/resize.d.ts +3 -2
- package/dist/images/upload.d.ts +4 -3
- package/dist/index-1e114d55.d.ts +26 -0
- package/dist/index-1f738e52.d.ts +22 -0
- package/dist/index-22309f0c.d.ts +23 -0
- package/dist/index-6ae3c86b.d.ts +63 -0
- package/dist/index-c52abc6d.d.ts +90 -0
- package/dist/index.d.ts +30 -19
- package/dist/json.d.ts +4 -3
- package/dist/math/diffDate.d.ts +3 -2
- package/dist/math/index.d.ts +3 -30
- package/dist/math/positiveNumber.d.ts +3 -2
- package/dist/name/en.d.ts +4 -3
- package/dist/name/index.d.ts +3 -12
- package/dist/name/vi.d.ts +4 -3
- package/dist/object-43aaaf92.d.ts +80 -0
- package/dist/object.d.ts +1 -59
- package/dist/permission/index.d.ts +3 -2
- package/dist/permission/requestCamera.d.ts +1 -5
- package/dist/permission/requestDeviceOrientationControl.d.ts +1 -2
- package/dist/requestCamera-32b7dfc7.d.ts +14 -0
- package/dist/requestDeviceOrientationControl-b6458660.d.ts +11 -0
- package/dist/response/index.d.ts +7 -6
- package/dist/string/convertPathnameAndQuery.d.ts +6 -0
- package/dist/string/convertPathnameAndQuery.js +21 -0
- package/dist/string/convertPathnameAndQuery.js.map +1 -0
- package/dist/string/formatNumber.d.ts +3 -2
- package/dist/string/generatePassword.d.ts +3 -2
- package/dist/string/generateUUID.d.ts +3 -2
- package/dist/string/getTextBetweenCharByIndex.d.ts +3 -1
- package/dist/string/index.d.ts +6 -65
- package/dist/string/indexesOf.d.ts +3 -1
- package/dist/string/makeDaySlug.d.ts +4 -3
- package/dist/string/random.d.ts +10 -9
- package/dist/string/trimNull.d.ts +3 -2
- package/dist/string/url.d.ts +1 -27
- package/dist/string/url.js +5 -9
- package/dist/string/url.js.map +1 -1
- package/dist/url-4f3cd108.d.ts +48 -0
- package/esm/string/convertPathnameAndQuery.d.ts +4 -0
- package/esm/string/convertPathnameAndQuery.js +18 -0
- package/esm/string/convertPathnameAndQuery.js.map +1 -0
- package/esm/string/url.js +5 -9
- package/esm/string/url.js.map +1 -1
- package/package.json +1 -1
- package/src/string/convertPathnameAndQuery.ts +21 -0
- package/src/string/url.ts +5 -9
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function convertPathnameAndQuery(url) {
|
|
4
|
+
//
|
|
5
|
+
const arr = url.split("?");
|
|
6
|
+
const pathname = arr[0];
|
|
7
|
+
const query = {};
|
|
8
|
+
if (arr[1]) {
|
|
9
|
+
const _query = arr[1].split("&");
|
|
10
|
+
_query.map((item) => {
|
|
11
|
+
const __item = item.split("=");
|
|
12
|
+
query[__item[0]] = __item[1];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
pathname,
|
|
17
|
+
query,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.default = convertPathnameAndQuery;
|
|
21
|
+
//# sourceMappingURL=convertPathnameAndQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertPathnameAndQuery.js","sourceRoot":"","sources":["../../src/string/convertPathnameAndQuery.ts"],"names":[],"mappings":";;AAAA,SAAwB,uBAAuB,CAAC,GAAW;IAC1D,EAAE;IAEF,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,EAAS,CAAC;IAExB,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;QACX,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;KACH;IAED,OAAO;QACN,QAAQ;QACR,KAAK;KACL,CAAC;AACH,CAAC;AApBD,0CAoBC"}
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Format the input number with commas
|
|
3
3
|
* @example 1000000 -> 1,000,000
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
declare function formatNumber(num: number, prefix?: string): string;
|
|
6
|
+
|
|
7
|
+
export { formatNumber as default, formatNumber };
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* @param {Boolean} hard
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
declare function generatePassword(length?: number, hard?: boolean): string;
|
|
9
|
+
|
|
10
|
+
export { generatePassword as default, generatePassword };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare function generateUUID(): string;
|
|
2
|
+
|
|
3
|
+
export { generateUUID as default, generateUUID };
|
package/dist/string/index.d.ts
CHANGED
|
@@ -1,65 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export declare const makeString: (object?: any) => string;
|
|
9
|
-
/**
|
|
10
|
-
* toUpperCase
|
|
11
|
-
*/
|
|
12
|
-
export declare const toUpperCase: (str?: string) => string;
|
|
13
|
-
/**
|
|
14
|
-
* toLowerCase
|
|
15
|
-
*/
|
|
16
|
-
export declare const toLowerCase: (str?: string) => string;
|
|
17
|
-
/**
|
|
18
|
-
* toLowerCase
|
|
19
|
-
* @param {*} str
|
|
20
|
-
* @return {string}
|
|
21
|
-
*/
|
|
22
|
-
export declare const titleize: (str?: string) => string;
|
|
23
|
-
/**
|
|
24
|
-
* Convert only first charater to UpperCase
|
|
25
|
-
*/
|
|
26
|
-
export declare const capitalize: (str: string | any, lowercaseRest?: number) => any;
|
|
27
|
-
/**
|
|
28
|
-
* Convert first character from every single words to UpperCase
|
|
29
|
-
*/
|
|
30
|
-
export declare const capitalizeName: (str: string) => string;
|
|
31
|
-
export declare const clearUnicodeCharacters: (s: string, opt?: {
|
|
32
|
-
[key: string]: any;
|
|
33
|
-
}) => string;
|
|
34
|
-
import { makeDaySlug } from "./makeDaySlug";
|
|
35
|
-
import { generateUUID } from "./generateUUID";
|
|
36
|
-
import { formatNumber } from "./formatNumber";
|
|
37
|
-
import { generatePassword } from "./generatePassword";
|
|
38
|
-
import { trimNull } from "./trimNull";
|
|
39
|
-
declare const xstring: {
|
|
40
|
-
getBetween: (text: string, str1: string, str2?: string) => string;
|
|
41
|
-
makeString: (object?: any) => string;
|
|
42
|
-
makeDaySlug: typeof makeDaySlug;
|
|
43
|
-
toUpperCase: (str?: string) => string;
|
|
44
|
-
toLowerCase: (str?: string) => string;
|
|
45
|
-
titleize: (str?: string) => string;
|
|
46
|
-
capitalize: (str: string | any, lowercaseRest?: number) => any;
|
|
47
|
-
capitalizeName: (str: string) => string;
|
|
48
|
-
clearUnicodeCharacters: (s: string, opt?: {
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
}) => string;
|
|
51
|
-
generateUUID: typeof generateUUID;
|
|
52
|
-
randAllCharacterByLength: (length?: number) => string;
|
|
53
|
-
randomStringByLength: (length: number, str?: string) => string;
|
|
54
|
-
formatNumber: typeof formatNumber;
|
|
55
|
-
generatePassword: typeof generatePassword;
|
|
56
|
-
trimNull: typeof trimNull;
|
|
57
|
-
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
58
|
-
getUrlParams: (parameter: string, staticURL?: string | undefined, decode?: boolean) => string | false | undefined;
|
|
59
|
-
isLink: (str: string) => boolean;
|
|
60
|
-
getFileNameWithoutExtension: (url: string) => string;
|
|
61
|
-
getFileNameWithExtension: (url: string) => string;
|
|
62
|
-
getFileExtension: (url: string) => string | undefined;
|
|
63
|
-
isImage: (url: string) => boolean;
|
|
64
|
-
};
|
|
65
|
-
export default xstring;
|
|
1
|
+
import './makeDaySlug.js';
|
|
2
|
+
import './generateUUID.js';
|
|
3
|
+
import './formatNumber.js';
|
|
4
|
+
import './generatePassword.js';
|
|
5
|
+
import './trimNull.js';
|
|
6
|
+
export { c as capitalize, d as capitalizeName, e as clearUnicodeCharacters, x as default, g as getBetween, m as makeString, b as titleize, a as toLowerCase, t as toUpperCase } from '../index-c52abc6d.js';
|
|
@@ -24,8 +24,9 @@ type DaySlugOptions = {
|
|
|
24
24
|
* Format the input number with commas
|
|
25
25
|
* @example 1000000 -> 1,000,000
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
declare function makeDaySlug(options?: DaySlugOptions): string;
|
|
28
28
|
declare const _default: {
|
|
29
29
|
makeDaySlug: typeof makeDaySlug;
|
|
30
|
-
};
|
|
31
|
-
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { _default as default, makeDaySlug };
|
package/dist/string/random.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const textLowCase = "abcdefghijklmnopqrstuvwxyz";
|
|
2
|
+
declare const numeric = "0123456789";
|
|
3
|
+
declare const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
4
|
+
declare const allCharacter = "\u0111\u0110a\u00E1\u00E0\u1EA3\u00E3\u1EA1\u0103\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u00E2\u1EA5\u1EA7\u1EA9\u1EAB\u1EADe\u00E9\u00E8\u1EBB\u1EBD\u1EB9\u00EA\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7o\u00F3\u00F2\u1ECF\u00F5\u1ECD\u00F4\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u01A1\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3i\u00ED\u00EC\u1EC9\u0129\u1ECBu\u00FA\u00F9\u1EE7\u0169\u1EE5\u01B0\u1EE9\u1EEB\u1EED\u1EEF\u1EF1y\u00FD\u1EF3\u1EF7\u1EF9\u1EF5A\u00C1\u00C0\u1EA2\u00C3\u1EA0\u0102\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u00C2\u1EA4\u1EA6\u1EA8\u1EAA\u1EACE\u00C9\u00C8\u1EBA\u1EBC\u1EB8\u00CA\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6O\u00D3\u00D2\u1ECE\u00D5\u1ECC\u00D4\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u01A0\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2I\u00CD\u00CC\u1EC8\u0128\u1ECAU\u00DA\u00D9\u1EE6\u0168\u1EE4\u01AF\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0Y\u00DD\u1EF2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}";
|
|
5
5
|
/**
|
|
6
6
|
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
declare const randAllCharacterByLength: (length?: number) => string;
|
|
9
|
+
declare const randomStringByLength: (length: number, str?: string) => string;
|
|
10
|
+
declare const randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
11
11
|
declare const random: {
|
|
12
12
|
randAllCharacterByLength: (length?: number) => string;
|
|
13
13
|
randomStringByLength: (length: number, str?: string) => string;
|
|
14
14
|
randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
15
|
-
};
|
|
16
|
-
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { allCharacter, random as default, numeric, punctuation, randAllCharacterByLength, randomStringAndNumberByLength, randomStringByLength, textLowCase };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare function trimNull(str: string): string;
|
|
2
|
+
|
|
3
|
+
export { trimNull as default, trimNull };
|
package/dist/string/url.d.ts
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
3
|
-
export declare const isLink: (str: string) => boolean;
|
|
4
|
-
export declare const getFileNameWithoutExtension: (url: string) => string;
|
|
5
|
-
export declare const getFileNameWithExtension: (url: string) => string;
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {string} url
|
|
9
|
-
* @return {string}
|
|
10
|
-
*/
|
|
11
|
-
export declare const getFileExtension: (url: string) => string | undefined;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {string} url
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export declare const isImage: (url: string) => boolean;
|
|
18
|
-
declare const xurl: {
|
|
19
|
-
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
20
|
-
getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
21
|
-
isLink: (str: string) => boolean;
|
|
22
|
-
getFileNameWithoutExtension: (url: string) => string;
|
|
23
|
-
getFileNameWithExtension: (url: string) => string;
|
|
24
|
-
getFileExtension: (url: string) => string | undefined;
|
|
25
|
-
isImage: (url: string) => boolean;
|
|
26
|
-
};
|
|
27
|
-
export default xurl;
|
|
1
|
+
export { a as addQueryParam, x as default, d as getFileExtension, c as getFileNameWithExtension, b as getFileNameWithoutExtension, g as getUrlParams, e as isImage, i as isLink } from '../url-4f3cd108.js';
|
package/dist/string/url.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isImage = exports.getFileExtension = exports.getFileNameWithExtension = exports.getFileNameWithoutExtension = exports.isLink = exports.getUrlParams = exports.addQueryParam = void 0;
|
|
4
|
-
const object_1 = require("../object");
|
|
5
4
|
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
6
5
|
const addQueryParam = (_url, key, value) => {
|
|
7
6
|
_url += (_url.split("?")[1] ? "&" : "?") + `${key}=${value}`;
|
|
@@ -35,20 +34,17 @@ const isLink = (str) => {
|
|
|
35
34
|
};
|
|
36
35
|
exports.isLink = isLink;
|
|
37
36
|
const getFileNameWithoutExtension = (url) => {
|
|
38
|
-
var _a, _b
|
|
39
|
-
|
|
40
|
-
return "";
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return ((_b = (_a = (0, exports.getFileNameWithExtension)(url)) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b[0]) || "";
|
|
41
39
|
};
|
|
42
40
|
exports.getFileNameWithoutExtension = getFileNameWithoutExtension;
|
|
43
41
|
const getFileNameWithExtension = (url) => {
|
|
44
|
-
|
|
42
|
+
url = url.replaceAll("\\", "/");
|
|
45
43
|
const _url = decodeURIComponent(url);
|
|
46
44
|
const m = `${_url.toString().match(/.*\/(.*)$/)}`;
|
|
47
|
-
if (m && m.length > 1) {
|
|
48
|
-
return
|
|
45
|
+
if (m && m.split(",").length > 1) {
|
|
46
|
+
return m.split(",")[1].replace(/(\?.*)|(\&.*)/, "");
|
|
49
47
|
}
|
|
50
|
-
if (!(0, object_1.isNull)(_url))
|
|
51
|
-
return url;
|
|
52
48
|
return "";
|
|
53
49
|
};
|
|
54
50
|
exports.getFileNameWithExtension = getFileNameWithExtension;
|
package/dist/string/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts"],"names":[],"mappings":";;;AAGA,IAAI,QAAQ,GAAG,sBAAsB,CAAC;AAE/B,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,KAAU,EAA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CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF;;;;GAIG;AACI,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IAEvB,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/E,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,IAAI,CAAC,CAAC;AACnB,CAAC,CAAC;AAVW,QAAA,OAAO,WAUlB;AAEF,MAAM,IAAI,GAAG,EAAE,aAAa,EAAb,qBAAa,EAAE,YAAY,EAAZ,oBAAY,EAAE,MAAM,EAAN,cAAM,EAAE,2BAA2B,EAA3B,mCAA2B,EAAE,wBAAwB,EAAxB,gCAAwB,EAAE,gBAAgB,EAAhB,wBAAgB,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC;AAEvI,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
declare const addQueryParam: (_url: string, key: string, value: any) => string;
|
|
2
|
+
declare const getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
3
|
+
declare const isLink: (str: string) => boolean;
|
|
4
|
+
declare const getFileNameWithoutExtension: (url: string) => string;
|
|
5
|
+
declare const getFileNameWithExtension: (url: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {string} url
|
|
9
|
+
* @return {string}
|
|
10
|
+
*/
|
|
11
|
+
declare const getFileExtension: (url: string) => string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {string} url
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
declare const isImage: (url: string) => boolean;
|
|
18
|
+
declare const xurl: {
|
|
19
|
+
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
20
|
+
getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
21
|
+
isLink: (str: string) => boolean;
|
|
22
|
+
getFileNameWithoutExtension: (url: string) => string;
|
|
23
|
+
getFileNameWithExtension: (url: string) => string;
|
|
24
|
+
getFileExtension: (url: string) => string | undefined;
|
|
25
|
+
isImage: (url: string) => boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare const url_addQueryParam: typeof addQueryParam;
|
|
29
|
+
declare const url_getFileExtension: typeof getFileExtension;
|
|
30
|
+
declare const url_getFileNameWithExtension: typeof getFileNameWithExtension;
|
|
31
|
+
declare const url_getFileNameWithoutExtension: typeof getFileNameWithoutExtension;
|
|
32
|
+
declare const url_getUrlParams: typeof getUrlParams;
|
|
33
|
+
declare const url_isImage: typeof isImage;
|
|
34
|
+
declare const url_isLink: typeof isLink;
|
|
35
|
+
declare namespace url {
|
|
36
|
+
export {
|
|
37
|
+
url_addQueryParam as addQueryParam,
|
|
38
|
+
xurl as default,
|
|
39
|
+
url_getFileExtension as getFileExtension,
|
|
40
|
+
url_getFileNameWithExtension as getFileNameWithExtension,
|
|
41
|
+
url_getFileNameWithoutExtension as getFileNameWithoutExtension,
|
|
42
|
+
url_getUrlParams as getUrlParams,
|
|
43
|
+
url_isImage as isImage,
|
|
44
|
+
url_isLink as isLink,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { addQueryParam as a, getFileNameWithoutExtension as b, getFileNameWithExtension as c, getFileExtension as d, isImage as e, getUrlParams as g, isLink as i, url as u, xurl as x };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function convertPathnameAndQuery(url) {
|
|
2
|
+
//
|
|
3
|
+
const arr = url.split("?");
|
|
4
|
+
const pathname = arr[0];
|
|
5
|
+
const query = {};
|
|
6
|
+
if (arr[1]) {
|
|
7
|
+
const _query = arr[1].split("&");
|
|
8
|
+
_query.map((item) => {
|
|
9
|
+
const __item = item.split("=");
|
|
10
|
+
query[__item[0]] = __item[1];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
pathname,
|
|
15
|
+
query,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=convertPathnameAndQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertPathnameAndQuery.js","sourceRoot":"","sources":["../../src/string/convertPathnameAndQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,GAAW;IAC1D,EAAE;IAEF,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,EAAS,CAAC;IAExB,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;QACX,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;KACH;IAED,OAAO;QACN,QAAQ;QACR,KAAK;KACL,CAAC;AACH,CAAC"}
|
package/esm/string/url.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isNull } from "../object";
|
|
2
1
|
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
3
2
|
export const addQueryParam = (_url, key, value) => {
|
|
4
3
|
_url += (_url.split("?")[1] ? "&" : "?") + `${key}=${value}`;
|
|
@@ -29,19 +28,16 @@ export const isLink = (str) => {
|
|
|
29
28
|
return urlRegex.test(str);
|
|
30
29
|
};
|
|
31
30
|
export const getFileNameWithoutExtension = (url) => {
|
|
32
|
-
var _a, _b
|
|
33
|
-
|
|
34
|
-
return "";
|
|
31
|
+
var _a, _b;
|
|
32
|
+
return ((_b = (_a = getFileNameWithExtension(url)) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b[0]) || "";
|
|
35
33
|
};
|
|
36
34
|
export const getFileNameWithExtension = (url) => {
|
|
37
|
-
|
|
35
|
+
url = url.replaceAll("\\", "/");
|
|
38
36
|
const _url = decodeURIComponent(url);
|
|
39
37
|
const m = `${_url.toString().match(/.*\/(.*)$/)}`;
|
|
40
|
-
if (m && m.length > 1) {
|
|
41
|
-
return
|
|
38
|
+
if (m && m.split(",").length > 1) {
|
|
39
|
+
return m.split(",")[1].replace(/(\?.*)|(\&.*)/, "");
|
|
42
40
|
}
|
|
43
|
-
if (!isNull(_url))
|
|
44
|
-
return url;
|
|
45
41
|
return "";
|
|
46
42
|
};
|
|
47
43
|
/**
|
package/esm/string/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts"],"names":[],"mappings":"AAGA,IAAI,QAAQ,GAAG,sBAAsB,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,KAAU,EAAE,EAAE;IACtE,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CA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AAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/E,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,IAAI,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC;AAEvI,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default function convertPathnameAndQuery(url: string) {
|
|
2
|
+
//
|
|
3
|
+
|
|
4
|
+
const arr = url.split("?");
|
|
5
|
+
|
|
6
|
+
const pathname = arr[0];
|
|
7
|
+
const query = {} as any;
|
|
8
|
+
|
|
9
|
+
if (arr[1]) {
|
|
10
|
+
const _query = arr[1].split("&");
|
|
11
|
+
_query.map((item) => {
|
|
12
|
+
const __item = item.split("=");
|
|
13
|
+
query[__item[0]] = __item[1];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
pathname,
|
|
19
|
+
query,
|
|
20
|
+
};
|
|
21
|
+
}
|
package/src/string/url.ts
CHANGED
|
@@ -38,22 +38,18 @@ export const isLink = (str: string) => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export const getFileNameWithoutExtension = (url: string) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return "";
|
|
41
|
+
return getFileNameWithExtension(url)?.split(".")?.[0] || "";
|
|
44
42
|
};
|
|
45
43
|
|
|
46
44
|
export const getFileNameWithExtension = (url: string): string => {
|
|
45
|
+
url = url.replaceAll("\\", "/");
|
|
47
46
|
const _url = decodeURIComponent(url);
|
|
48
47
|
|
|
49
|
-
const m = `${_url.toString().match(/.*\/(.*)$/)}
|
|
48
|
+
const m = `${_url.toString().match(/.*\/(.*)$/)}`;
|
|
50
49
|
|
|
51
|
-
if (m && m.length > 1) {
|
|
52
|
-
return m
|
|
50
|
+
if (m && m.split(",").length > 1) {
|
|
51
|
+
return m.split(",")[1].replace(/(\?.*)|(\&.*)/, "");
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
if (!isNull(_url)) return url;
|
|
56
|
-
|
|
57
53
|
return "";
|
|
58
54
|
};
|
|
59
55
|
|