@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.
@@ -231,19 +231,30 @@
231
231
  return /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}(\/revs\/[0-9]{1,20})?$/.test(src);
232
232
  };
233
233
 
234
+ const PLACEHOLDER = 'http://_';
235
+ const joinPath = (...path) => {
236
+ const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
237
+ const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
238
+ const pathname = cleanPath(urls.map((_) => _.pathname));
239
+ const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
240
+ const hash = urls.find((_) => _.hash)?.hash;
241
+ return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
242
+ };
243
+ const joinSearchParams = (...list) => {
244
+ const result = new URLSearchParams();
245
+ for (const searchParams of list) {
246
+ for (const [k, v] of searchParams) {
247
+ result.set(k, v);
248
+ }
249
+ }
250
+ return result;
251
+ };
252
+ const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
253
+
234
254
  const isURL = (href) => Boolean(href?.includes(':'));
235
255
  const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
236
256
  const isHash = (href) => Boolean(href?.startsWith('#'));
237
257
  const withoutQuery = (href) => (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
238
- const joinPath = (...path) => path
239
- .filter(Boolean)
240
- .join('/')
241
- .replace(/\/+/g, '/')
242
- .replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
243
- .replace(/^file:/, 'file:/')
244
- .replace(/\/(\?|&|#[^!])/g, '$1')
245
- .replace(/\?/g, '&')
246
- .replace('&', '?');
247
258
  const hasPrefix = (href) => (prefix) => Boolean(href &&
248
259
  prefix &&
249
260
  href.startsWith(prefix) &&
@@ -255,8 +266,8 @@
255
266
  isLocalURL: isLocalURL,
256
267
  isHash: isHash,
257
268
  withoutQuery: withoutQuery,
258
- joinPath: joinPath,
259
- hasPrefix: hasPrefix
269
+ hasPrefix: hasPrefix,
270
+ joinPath: joinPath
260
271
  });
261
272
 
262
273
  const API_PREFIX = '/api/';
@@ -10505,7 +10516,7 @@
10505
10516
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
10506
10517
  });
10507
10518
 
10508
- const packageVersion = "0.14.763";
10519
+ const packageVersion = "0.14.764";
10509
10520
 
10510
10521
  exports.Blocks = Blocks;
10511
10522
  exports.ContentPage = ContentPage;