druxt 0.25.2-dev.20261119071821 → 0.25.2-dev.20261119231013
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/druxt.esm.js +17 -3
- package/dist/druxt.ssr.js +17 -3
- package/package.json +1 -1
package/dist/druxt.esm.js
CHANGED
|
@@ -204,6 +204,20 @@ const DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
|
|
|
204
204
|
const CACHE_SAFE_OPTIONS = ["validateStatus", "timeout"];
|
|
205
205
|
const requestOptions = ({ bypassCache } = {}) => bypassCache ? [{ bypassCache: true }] : [];
|
|
206
206
|
const isNested = (value) => value !== null && typeof value === "object";
|
|
207
|
+
const urlPath = (url) => {
|
|
208
|
+
try {
|
|
209
|
+
return new URL(url).pathname.replace(/\/$/, "");
|
|
210
|
+
} catch (e) {
|
|
211
|
+
return "";
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const stripOrigin = (href, basePath) => {
|
|
215
|
+
if (!/^[a-z][a-z\d+.-]*:\/\//i.test(href || ""))
|
|
216
|
+
return href;
|
|
217
|
+
const url = new URL(href);
|
|
218
|
+
const path = basePath && url.pathname.startsWith(`${basePath}/`) ? url.pathname.slice(basePath.length) : url.pathname;
|
|
219
|
+
return `${path.replace(/^\/{2,}/, "/")}${url.search}${url.hash}`;
|
|
220
|
+
};
|
|
207
221
|
const stringifyNested = (value, name) => Object.entries(value).map(([key, item]) => {
|
|
208
222
|
if (!name && (!isNested(item) || Array.isArray(item)))
|
|
209
223
|
return stringify({ [key]: item });
|
|
@@ -464,9 +478,9 @@ class DruxtClient {
|
|
|
464
478
|
const err = { response: { statusText: "Invalid JSON:API endpoint" } };
|
|
465
479
|
this.error(err, { url });
|
|
466
480
|
}
|
|
467
|
-
const
|
|
481
|
+
const basePath = urlPath(this.options.baseUrl);
|
|
468
482
|
index = Object.fromEntries(Object.entries(index).map(([key, value]) => {
|
|
469
|
-
value.href = value.href
|
|
483
|
+
value.href = stripOrigin(value.href, basePath);
|
|
470
484
|
return [key, value];
|
|
471
485
|
}));
|
|
472
486
|
const documents = [data];
|
|
@@ -564,7 +578,7 @@ const cacheClearHandler = (secret) => (req, res) => {
|
|
|
564
578
|
};
|
|
565
579
|
|
|
566
580
|
var name = "druxt";
|
|
567
|
-
var version = "0.25.2-dev.
|
|
581
|
+
var version = "0.25.2-dev.20261119231013";
|
|
568
582
|
var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
|
|
569
583
|
var keywords = [
|
|
570
584
|
"cms",
|
package/dist/druxt.ssr.js
CHANGED
|
@@ -217,6 +217,20 @@ const DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
|
|
|
217
217
|
const CACHE_SAFE_OPTIONS = ["validateStatus", "timeout"];
|
|
218
218
|
const requestOptions = ({ bypassCache } = {}) => bypassCache ? [{ bypassCache: true }] : [];
|
|
219
219
|
const isNested = (value) => value !== null && typeof value === "object";
|
|
220
|
+
const urlPath = (url) => {
|
|
221
|
+
try {
|
|
222
|
+
return new URL(url).pathname.replace(/\/$/, "");
|
|
223
|
+
} catch (e) {
|
|
224
|
+
return "";
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const stripOrigin = (href, basePath) => {
|
|
228
|
+
if (!/^[a-z][a-z\d+.-]*:\/\//i.test(href || ""))
|
|
229
|
+
return href;
|
|
230
|
+
const url = new URL(href);
|
|
231
|
+
const path = basePath && url.pathname.startsWith(`${basePath}/`) ? url.pathname.slice(basePath.length) : url.pathname;
|
|
232
|
+
return `${path.replace(/^\/{2,}/, "/")}${url.search}${url.hash}`;
|
|
233
|
+
};
|
|
220
234
|
const stringifyNested = (value, name) => Object.entries(value).map(([key, item]) => {
|
|
221
235
|
if (!name && (!isNested(item) || Array.isArray(item)))
|
|
222
236
|
return querystring.stringify({ [key]: item });
|
|
@@ -477,9 +491,9 @@ class DruxtClient {
|
|
|
477
491
|
const err = { response: { statusText: "Invalid JSON:API endpoint" } };
|
|
478
492
|
this.error(err, { url });
|
|
479
493
|
}
|
|
480
|
-
const
|
|
494
|
+
const basePath = urlPath(this.options.baseUrl);
|
|
481
495
|
index = Object.fromEntries(Object.entries(index).map(([key, value]) => {
|
|
482
|
-
value.href = value.href
|
|
496
|
+
value.href = stripOrigin(value.href, basePath);
|
|
483
497
|
return [key, value];
|
|
484
498
|
}));
|
|
485
499
|
const documents = [data];
|
|
@@ -577,7 +591,7 @@ const cacheClearHandler = (secret) => (req, res) => {
|
|
|
577
591
|
};
|
|
578
592
|
|
|
579
593
|
var name = "druxt";
|
|
580
|
-
var version = "0.25.2-dev.
|
|
594
|
+
var version = "0.25.2-dev.20261119231013";
|
|
581
595
|
var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
|
|
582
596
|
var keywords = [
|
|
583
597
|
"cms",
|