@redneckz/wildless-cms-uni-blocks 0.14.764 → 0.14.765

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.
@@ -0,0 +1,2 @@
1
+ export declare const joinPath: (...path: (string | undefined | null)[]) => string;
2
+ export declare const joinSearchParams: (...list: URLSearchParams[]) => URLSearchParams;
@@ -1,7 +1,7 @@
1
1
  import { type Target } from '../model/LinkProps';
2
- export declare const isURL: (href: string | undefined) => href is `${string}:${string}`;
2
+ export declare const isURL: (href: string | undefined | null) => href is `${string}:${string}`;
3
3
  export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
4
4
  export declare const isHash: (href: string | undefined) => href is `#${string}`;
5
5
  export declare const withoutQuery: (href: string | undefined) => string;
6
- export declare const joinPath: (...path: (string | undefined | null)[]) => string;
6
+ export { joinPath } from './joinPath';
7
7
  export declare const hasPrefix: (href?: string) => (prefix?: string) => boolean;
@@ -0,0 +1,2 @@
1
+ export declare const joinPath: (...path: (string | undefined | null)[]) => string;
2
+ export declare const joinSearchParams: (...list: URLSearchParams[]) => URLSearchParams;
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.joinSearchParams = exports.joinPath = void 0;
3
+ const PLACEHOLDER = 'http://_';
4
+ const joinPath = (...path) => {
5
+ const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
6
+ const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
7
+ const pathname = cleanPath(urls.map((_) => _.pathname));
8
+ const query = (0, exports.joinSearchParams)(...urls.map((_) => _.searchParams)).toString();
9
+ const hash = urls.find((_) => _.hash)?.hash;
10
+ return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
11
+ };
12
+ exports.joinPath = joinPath;
13
+ const joinSearchParams = (...list) => {
14
+ const result = new URLSearchParams();
15
+ for (const searchParams of list) {
16
+ for (const [k, v] of searchParams) {
17
+ result.set(k, v);
18
+ }
19
+ }
20
+ return result;
21
+ };
22
+ exports.joinSearchParams = joinSearchParams;
23
+ const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
24
+ //# sourceMappingURL=joinPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joinPath.js","sourceRoot":"","sources":["../../src/utils/joinPath.ts"],"names":[],"mappings":";;AAAA,MAAM,WAAW,GAAG,UAAU,CAAC;AAExB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,EAAE,MAAM,CAAC;IAClE,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,IAAA,wBAAgB,EAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAE5C,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrF,CAAC,CAAC;AARW,QAAA,QAAQ,YAQnB;AAEK,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAuB,EAAmB,EAAE;IAC9E,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,YAAY,IAAI,IAAI,EAAE;QAC/B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,YAAY,EAAE;YACjC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAClB;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B;AAEF,MAAM,SAAS,GAAG,CAAC,SAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type Target } from '../model/LinkProps';
2
- export declare const isURL: (href: string | undefined) => href is `${string}:${string}`;
2
+ export declare const isURL: (href: string | undefined | null) => href is `${string}:${string}`;
3
3
  export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
4
4
  export declare const isHash: (href: string | undefined) => href is `#${string}`;
5
5
  export declare const withoutQuery: (href: string | undefined) => string;
6
- export declare const joinPath: (...path: (string | undefined | null)[]) => string;
6
+ export { joinPath } from './joinPath';
7
7
  export declare const hasPrefix: (href?: string) => (prefix?: string) => boolean;
@@ -8,16 +8,8 @@ const isHash = (href) => Boolean(href?.startsWith('#'));
8
8
  exports.isHash = isHash;
9
9
  const withoutQuery = (href) => (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
10
10
  exports.withoutQuery = withoutQuery;
11
- const joinPath = (...path) => path
12
- .filter(Boolean)
13
- .join('/')
14
- .replace(/\/+/g, '/')
15
- .replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
16
- .replace(/^file:/, 'file:/')
17
- .replace(/\/(\?|&|#[^!])/g, '$1')
18
- .replace(/\?/g, '&')
19
- .replace('&', '?');
20
- exports.joinPath = joinPath;
11
+ var joinPath_1 = require("./joinPath");
12
+ Object.defineProperty(exports, "joinPath", { enumerable: true, get: function () { return joinPath_1.joinPath; } });
21
13
  const hasPrefix = (href) => (prefix) => Boolean(href &&
22
14
  prefix &&
23
15
  href.startsWith(prefix) &&
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":";;AAEO,MAAM,KAAK,GAAG,CAAC,IAAwB,EAAiC,EAAE,CAC/E,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AADlB,QAAA,KAAK,SACa;AAExB,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAe,EAAE,EAAE,CACtE,OAAO,CAAC,IAAI,IAAI,CAAC,IAAA,aAAK,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC;AADtD,QAAA,UAAU,cAC4C;AAE5D,MAAM,MAAM,GAAG,CAAC,IAAwB,EAAwB,EAAE,CACvE,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AADpB,QAAA,MAAM,UACc;AAE1B,MAAM,YAAY,GAAG,CAAC,IAAwB,EAAU,EAAE,CAC/D,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AADzC,QAAA,YAAY,gBAC6B;AAE/C,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE,CACzE,IAAI;KACD,MAAM,CAAC,OAAO,CAAC;KACf,IAAI,CAAC,GAAG,CAAC;KACT,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;KACpB,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,4CAA4C;KACzE,OAAO,CAAC,QAA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AC;AADzC,QAAA,YAAY,gBAC6B;AAEtD,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEV,MAAM,SAAS,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,MAAe,EAAE,EAAE,CAC9D,OAAO,CACL,IAAI;IACF,MAAM;IACN,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACvB,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CACrE,CAAC;AANS,QAAA,SAAS,aAMlB"}
@@ -0,0 +1,2 @@
1
+ export declare const joinPath: (...path: (string | undefined | null)[]) => string;
2
+ export declare const joinSearchParams: (...list: URLSearchParams[]) => URLSearchParams;
@@ -0,0 +1,20 @@
1
+ const PLACEHOLDER = 'http://_';
2
+ export const joinPath = (...path) => {
3
+ const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
4
+ const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
5
+ const pathname = cleanPath(urls.map((_) => _.pathname));
6
+ const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
7
+ const hash = urls.find((_) => _.hash)?.hash;
8
+ return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
9
+ };
10
+ export const joinSearchParams = (...list) => {
11
+ const result = new URLSearchParams();
12
+ for (const searchParams of list) {
13
+ for (const [k, v] of searchParams) {
14
+ result.set(k, v);
15
+ }
16
+ }
17
+ return result;
18
+ };
19
+ const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
20
+ //# sourceMappingURL=joinPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joinPath.js","sourceRoot":"","sources":["../../src/utils/joinPath.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE;IACzE,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ChB,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,SAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type Target } from '../model/LinkProps';
2
- export declare const isURL: (href: string | undefined) => href is `${string}:${string}`;
2
+ export declare const isURL: (href: string | undefined | null) => href is `${string}:${string}`;
3
3
  export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
4
4
  export declare const isHash: (href: string | undefined) => href is `#${string}`;
5
5
  export declare const withoutQuery: (href: string | undefined) => string;
6
- export declare const joinPath: (...path: (string | undefined | null)[]) => string;
6
+ export { joinPath } from './joinPath';
7
7
  export declare const hasPrefix: (href?: string) => (prefix?: string) => boolean;
@@ -2,15 +2,7 @@ export const isURL = (href) => Boolean(href?.includes(':'));
2
2
  export const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
3
3
  export const isHash = (href) => Boolean(href?.startsWith('#'));
4
4
  export const withoutQuery = (href) => (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
5
- export const joinPath = (...path) => path
6
- .filter(Boolean)
7
- .join('/')
8
- .replace(/\/+/g, '/')
9
- .replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
10
- .replace(/^file:/, 'file:/')
11
- .replace(/\/(\?|&|#[^!])/g, '$1')
12
- .replace(/\?/g, '&')
13
- .replace('&', '?');
5
+ export { joinPath } from './joinPath.js';
14
6
  export const hasPrefix = (href) => (prefix) => Boolean(href &&
15
7
  prefix &&
16
8
  href.startsWith(prefix) &&
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAwB,EAAiC,EAAE,CAC/E,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAA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E,CAAC"}
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAA+B,EAAiC,EAAE,CACtF,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAe,EAAE,EAAE,CACtE,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAwB,EAAwB,EAAE,CACvE,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAwB,EAAU,EAAE,CAC/D,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,MAAe,EAAE,EAAE,CAC9D,OAAO,CACL,IAAI;IACF,MAAM;IACN,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACvB,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CACrE,CAAC"}
@@ -0,0 +1,24 @@
1
+ const PLACEHOLDER = 'http://_';
2
+
3
+ export const joinPath = (...path: (string | undefined | null)[]): string => {
4
+ const urls = path.filter(Boolean).map((_) => new URL(_ as string, PLACEHOLDER));
5
+ const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
6
+ const pathname = cleanPath(urls.map((_) => _.pathname));
7
+ const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
8
+ const hash = urls.find((_) => _.hash)?.hash;
9
+
10
+ return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
11
+ };
12
+
13
+ export const joinSearchParams = (...list: URLSearchParams[]): URLSearchParams => {
14
+ const result = new URLSearchParams();
15
+ for (const searchParams of list) {
16
+ for (const [k, v] of searchParams) {
17
+ result.set(k, v);
18
+ }
19
+ }
20
+
21
+ return result;
22
+ };
23
+
24
+ const cleanPath = (pathParts: string[]) => pathParts.join('/').replace(/\/+/g, '/');
@@ -1,6 +1,6 @@
1
1
  import { type Target } from '../model/LinkProps';
2
2
 
3
- export const isURL = (href: string | undefined): href is `${string}:${string}` =>
3
+ export const isURL = (href: string | undefined | null): href is `${string}:${string}` =>
4
4
  Boolean(href?.includes(':'));
5
5
 
6
6
  export const isLocalURL = (href: string | undefined, target?: Target) =>
@@ -12,16 +12,7 @@ export const isHash = (href: string | undefined): href is `#${string}` =>
12
12
  export const withoutQuery = (href: string | undefined): string =>
13
13
  (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
14
14
 
15
- export const joinPath = (...path: (string | undefined | null)[]): string =>
16
- path
17
- .filter(Boolean)
18
- .join('/')
19
- .replace(/\/+/g, '/')
20
- .replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
21
- .replace(/^file:/, 'file:/')
22
- .replace(/\/(\?|&|#[^!])/g, '$1')
23
- .replace(/\?/g, '&')
24
- .replace('&', '?');
15
+ export { joinPath } from './joinPath';
25
16
 
26
17
  export const hasPrefix = (href?: string) => (prefix?: string) =>
27
18
  Boolean(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.764",
3
+ "version": "0.14.765",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -0,0 +1,24 @@
1
+ const PLACEHOLDER = 'http://_';
2
+
3
+ export const joinPath = (...path: (string | undefined | null)[]): string => {
4
+ const urls = path.filter(Boolean).map((_) => new URL(_ as string, PLACEHOLDER));
5
+ const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
6
+ const pathname = cleanPath(urls.map((_) => _.pathname));
7
+ const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
8
+ const hash = urls.find((_) => _.hash)?.hash;
9
+
10
+ return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
11
+ };
12
+
13
+ export const joinSearchParams = (...list: URLSearchParams[]): URLSearchParams => {
14
+ const result = new URLSearchParams();
15
+ for (const searchParams of list) {
16
+ for (const [k, v] of searchParams) {
17
+ result.set(k, v);
18
+ }
19
+ }
20
+
21
+ return result;
22
+ };
23
+
24
+ const cleanPath = (pathParts: string[]) => pathParts.join('/').replace(/\/+/g, '/');
package/src/utils/url.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Target } from '../model/LinkProps';
2
2
 
3
- export const isURL = (href: string | undefined): href is `${string}:${string}` =>
3
+ export const isURL = (href: string | undefined | null): href is `${string}:${string}` =>
4
4
  Boolean(href?.includes(':'));
5
5
 
6
6
  export const isLocalURL = (href: string | undefined, target?: Target) =>
@@ -12,16 +12,7 @@ export const isHash = (href: string | undefined): href is `#${string}` =>
12
12
  export const withoutQuery = (href: string | undefined): string =>
13
13
  (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
14
14
 
15
- export const joinPath = (...path: (string | undefined | null)[]): string =>
16
- path
17
- .filter(Boolean)
18
- .join('/')
19
- .replace(/\/+/g, '/')
20
- .replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
21
- .replace(/^file:/, 'file:/')
22
- .replace(/\/(\?|&|#[^!])/g, '$1')
23
- .replace(/\?/g, '&')
24
- .replace('&', '?');
15
+ export { joinPath } from './joinPath';
25
16
 
26
17
  export const hasPrefix = (href?: string) => (prefix?: string) =>
27
18
  Boolean(