@jsenv/core 39.10.2 → 39.11.0
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/jsenv_core.js
CHANGED
|
@@ -19480,11 +19480,14 @@ const generateHtmlForDirectory = (directoryContentItems) => {
|
|
|
19480
19480
|
directoryUrl = assertAndNormalizeDirectoryUrl(directoryUrl);
|
|
19481
19481
|
|
|
19482
19482
|
const htmlForDirectory = String(readFileSync(htmlFileUrlForDirectory));
|
|
19483
|
-
const directoryRelativeUrl = urlToRelativeUrl(directoryUrl, rootDirectoryUrl);
|
|
19484
19483
|
const replacers = {
|
|
19485
19484
|
directoryUrl,
|
|
19486
19485
|
directoryNav: () =>
|
|
19487
|
-
generateDirectoryNav(
|
|
19486
|
+
generateDirectoryNav(directoryUrl, {
|
|
19487
|
+
rootDirectoryUrl,
|
|
19488
|
+
rootDirectoryUrlForServer:
|
|
19489
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
19490
|
+
}),
|
|
19488
19491
|
directoryContent: () => generateDirectoryContent(directoryContentItems),
|
|
19489
19492
|
};
|
|
19490
19493
|
const html = replacePlaceholders$1(htmlForDirectory, replacers);
|
|
@@ -19514,47 +19517,60 @@ const generateHtmlForENOENT = (
|
|
|
19514
19517
|
ancestorDirectoryUrl,
|
|
19515
19518
|
ancestorDirectoryRelativeUrl,
|
|
19516
19519
|
ancestorDirectoryNav: () =>
|
|
19517
|
-
generateDirectoryNav(
|
|
19520
|
+
generateDirectoryNav(ancestorDirectoryUrl, {
|
|
19521
|
+
rootDirectoryUrl,
|
|
19522
|
+
rootDirectoryUrlForServer:
|
|
19523
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
19524
|
+
}),
|
|
19518
19525
|
ancestorDirectoryContent: () =>
|
|
19519
19526
|
generateDirectoryContent(directoryContentItems),
|
|
19520
19527
|
};
|
|
19521
19528
|
const html = replacePlaceholders$1(htmlFor404AndAncestorDir, replacers);
|
|
19522
19529
|
return html;
|
|
19523
19530
|
};
|
|
19524
|
-
const generateDirectoryNav = (
|
|
19531
|
+
const generateDirectoryNav = (
|
|
19532
|
+
entryDirectoryUrl,
|
|
19533
|
+
{ rootDirectoryUrl, rootDirectoryUrlForServer },
|
|
19534
|
+
) => {
|
|
19535
|
+
const entryDirectoryRelativeUrl = urlToRelativeUrl(
|
|
19536
|
+
entryDirectoryUrl,
|
|
19537
|
+
rootDirectoryUrl,
|
|
19538
|
+
);
|
|
19539
|
+
const isDir = entryDirectoryRelativeUrl.endsWith("/");
|
|
19525
19540
|
const rootDirectoryUrlName = urlToFilename$1(rootDirectoryUrl);
|
|
19526
|
-
const relativeUrlWithRoot = relativeUrl
|
|
19527
|
-
? `${rootDirectoryUrlName}/${relativeUrl}`
|
|
19528
|
-
: `${rootDirectoryUrlName}/`;
|
|
19529
|
-
const isDir = relativeUrlWithRoot.endsWith("/");
|
|
19530
|
-
const parts = isDir
|
|
19531
|
-
? relativeUrlWithRoot.slice(0, -1).split("/")
|
|
19532
|
-
: relativeUrlWithRoot.split("/");
|
|
19533
19541
|
const items = [];
|
|
19534
|
-
items.push({
|
|
19535
|
-
href: "/",
|
|
19536
|
-
text: "/",
|
|
19537
|
-
});
|
|
19538
19542
|
let dirPartsHtml = "";
|
|
19543
|
+
const parts =
|
|
19544
|
+
`${rootDirectoryUrlName}/${entryDirectoryRelativeUrl.slice(0, -1)}`.split(
|
|
19545
|
+
"/",
|
|
19546
|
+
);
|
|
19539
19547
|
let i = 0;
|
|
19540
19548
|
while (i < parts.length) {
|
|
19541
19549
|
const part = parts[i];
|
|
19542
|
-
const
|
|
19543
|
-
|
|
19544
|
-
|
|
19545
|
-
|
|
19550
|
+
const directoryRelativeUrl = `${parts.slice(1, i + 1).join("/")}`;
|
|
19551
|
+
const directoryUrl =
|
|
19552
|
+
directoryRelativeUrl === ""
|
|
19553
|
+
? rootDirectoryUrl
|
|
19554
|
+
: new URL(`${directoryRelativeUrl}/`, rootDirectoryUrl).href;
|
|
19555
|
+
let href =
|
|
19556
|
+
directoryUrl === rootDirectoryUrlForServer ||
|
|
19557
|
+
urlIsInsideOf(directoryUrl, rootDirectoryUrlForServer)
|
|
19558
|
+
? urlToRelativeUrl(directoryUrl, rootDirectoryUrlForServer)
|
|
19559
|
+
: directoryUrl;
|
|
19560
|
+
if (href === "") {
|
|
19561
|
+
href = `/${directoryContentMagicName}`;
|
|
19562
|
+
}
|
|
19546
19563
|
const text = part;
|
|
19547
|
-
const isLastPart = i === parts.length - 1;
|
|
19548
19564
|
items.push({
|
|
19549
19565
|
href,
|
|
19550
19566
|
text,
|
|
19551
|
-
isCurrent: isLastPart,
|
|
19552
19567
|
});
|
|
19553
19568
|
i++;
|
|
19554
19569
|
}
|
|
19555
19570
|
i = 0;
|
|
19556
|
-
for (const { href, text
|
|
19557
|
-
|
|
19571
|
+
for (const { href, text } of items) {
|
|
19572
|
+
const isLastPart = i === parts.length - 1;
|
|
19573
|
+
if (isLastPart) {
|
|
19558
19574
|
dirPartsHtml += `
|
|
19559
19575
|
<span class="directory_nav_item" data-current>
|
|
19560
19576
|
${text}
|
|
@@ -19565,10 +19581,8 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
19565
19581
|
<a class="directory_nav_item" href="${href}">
|
|
19566
19582
|
${text}
|
|
19567
19583
|
</a>`;
|
|
19568
|
-
|
|
19569
|
-
dirPartsHtml += `
|
|
19584
|
+
dirPartsHtml += `
|
|
19570
19585
|
<span class="directory_separator">/</span>`;
|
|
19571
|
-
}
|
|
19572
19586
|
i++;
|
|
19573
19587
|
}
|
|
19574
19588
|
if (isDir) {
|
|
@@ -19577,12 +19591,15 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
19577
19591
|
}
|
|
19578
19592
|
return dirPartsHtml;
|
|
19579
19593
|
};
|
|
19580
|
-
const generateDirectoryContentItems = (
|
|
19594
|
+
const generateDirectoryContentItems = (
|
|
19595
|
+
directoryUrl,
|
|
19596
|
+
rootDirectoryUrlForServer,
|
|
19597
|
+
) => {
|
|
19581
19598
|
let firstExistingDirectoryUrl = new URL("./", directoryUrl);
|
|
19582
19599
|
while (!existsSync(firstExistingDirectoryUrl)) {
|
|
19583
19600
|
firstExistingDirectoryUrl = new URL("../", firstExistingDirectoryUrl);
|
|
19584
|
-
if (!urlIsInsideOf(firstExistingDirectoryUrl,
|
|
19585
|
-
firstExistingDirectoryUrl = new URL(
|
|
19601
|
+
if (!urlIsInsideOf(firstExistingDirectoryUrl, rootDirectoryUrlForServer)) {
|
|
19602
|
+
firstExistingDirectoryUrl = new URL(rootDirectoryUrlForServer);
|
|
19586
19603
|
break;
|
|
19587
19604
|
}
|
|
19588
19605
|
}
|
|
@@ -19592,37 +19609,42 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
19592
19609
|
const fileUrlObject = new URL(filename, firstExistingDirectoryUrl);
|
|
19593
19610
|
fileUrls.push(fileUrlObject);
|
|
19594
19611
|
}
|
|
19612
|
+
let rootDirectoryUrl = rootDirectoryUrlForServer;
|
|
19595
19613
|
package_workspaces: {
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19599
|
-
const packageDirectoryUrl = lookupPackageDirectory(rootDirectoryUrl);
|
|
19614
|
+
const packageDirectoryUrl = lookupPackageDirectory(
|
|
19615
|
+
rootDirectoryUrlForServer,
|
|
19616
|
+
);
|
|
19600
19617
|
if (!packageDirectoryUrl) {
|
|
19601
19618
|
break package_workspaces;
|
|
19602
19619
|
}
|
|
19603
|
-
if (String(packageDirectoryUrl) === String(
|
|
19620
|
+
if (String(packageDirectoryUrl) === String(rootDirectoryUrlForServer)) {
|
|
19604
19621
|
break package_workspaces;
|
|
19605
19622
|
}
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
|
|
19624
|
-
|
|
19625
|
-
|
|
19623
|
+
rootDirectoryUrl = packageDirectoryUrl;
|
|
19624
|
+
if (
|
|
19625
|
+
String(firstExistingDirectoryUrl) === String(rootDirectoryUrlForServer)
|
|
19626
|
+
) {
|
|
19627
|
+
let packageContent;
|
|
19628
|
+
try {
|
|
19629
|
+
packageContent = JSON.parse(
|
|
19630
|
+
readFileSync(new URL("package.json", packageDirectoryUrl), "utf8"),
|
|
19631
|
+
);
|
|
19632
|
+
} catch {
|
|
19633
|
+
break package_workspaces;
|
|
19634
|
+
}
|
|
19635
|
+
const { workspaces } = packageContent;
|
|
19636
|
+
if (Array.isArray(workspaces)) {
|
|
19637
|
+
for (const workspace of workspaces) {
|
|
19638
|
+
const workspaceUrlObject = new URL(workspace, packageDirectoryUrl);
|
|
19639
|
+
const workspaceUrl = workspaceUrlObject.href;
|
|
19640
|
+
if (workspaceUrl.endsWith("*")) {
|
|
19641
|
+
const directoryUrl = ensurePathnameTrailingSlash(
|
|
19642
|
+
workspaceUrl.slice(0, -1),
|
|
19643
|
+
);
|
|
19644
|
+
fileUrls.push(new URL(directoryUrl));
|
|
19645
|
+
} else {
|
|
19646
|
+
fileUrls.push(ensurePathnameTrailingSlash(workspaceUrlObject));
|
|
19647
|
+
}
|
|
19626
19648
|
}
|
|
19627
19649
|
}
|
|
19628
19650
|
}
|
|
@@ -19646,14 +19668,18 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
19646
19668
|
sortedUrl,
|
|
19647
19669
|
firstExistingDirectoryUrl,
|
|
19648
19670
|
);
|
|
19649
|
-
const
|
|
19671
|
+
const fileUrlRelativeToServer = urlToRelativeUrl(
|
|
19672
|
+
sortedUrl,
|
|
19673
|
+
rootDirectoryUrlForServer,
|
|
19674
|
+
);
|
|
19650
19675
|
const type = fileUrlRelativeToParent.endsWith("/") ? "dir" : "file";
|
|
19651
19676
|
items.push({
|
|
19652
19677
|
type,
|
|
19653
19678
|
fileUrlRelativeToParent,
|
|
19654
|
-
|
|
19679
|
+
fileUrlRelativeToServer,
|
|
19655
19680
|
});
|
|
19656
19681
|
}
|
|
19682
|
+
items.rootDirectoryUrlForServer = rootDirectoryUrlForServer;
|
|
19657
19683
|
items.rootDirectoryUrl = rootDirectoryUrl;
|
|
19658
19684
|
items.firstExistingDirectoryUrl = firstExistingDirectoryUrl;
|
|
19659
19685
|
return items;
|
|
@@ -19664,11 +19690,15 @@ const generateDirectoryContent = (directoryContentItems) => {
|
|
|
19664
19690
|
}
|
|
19665
19691
|
let html = `<ul class="directory_content">`;
|
|
19666
19692
|
for (const directoryContentItem of directoryContentItems) {
|
|
19667
|
-
const { type, fileUrlRelativeToParent,
|
|
19693
|
+
const { type, fileUrlRelativeToParent, fileUrlRelativeToServer } =
|
|
19668
19694
|
directoryContentItem;
|
|
19695
|
+
let href = fileUrlRelativeToServer;
|
|
19696
|
+
if (href === "") {
|
|
19697
|
+
href = `${directoryContentMagicName}`;
|
|
19698
|
+
}
|
|
19669
19699
|
html += `
|
|
19670
19700
|
<li class="directory_child" data-type="${type}">
|
|
19671
|
-
<a href="/${
|
|
19701
|
+
<a href="/${href}">${fileUrlRelativeToParent}</a>
|
|
19672
19702
|
</li>`;
|
|
19673
19703
|
}
|
|
19674
19704
|
html += `\n </ul>`;
|
package/package.json
CHANGED
|
@@ -182,11 +182,14 @@ const generateHtmlForDirectory = (directoryContentItems) => {
|
|
|
182
182
|
directoryUrl = assertAndNormalizeDirectoryUrl(directoryUrl);
|
|
183
183
|
|
|
184
184
|
const htmlForDirectory = String(readFileSync(htmlFileUrlForDirectory));
|
|
185
|
-
const directoryRelativeUrl = urlToRelativeUrl(directoryUrl, rootDirectoryUrl);
|
|
186
185
|
const replacers = {
|
|
187
186
|
directoryUrl,
|
|
188
187
|
directoryNav: () =>
|
|
189
|
-
generateDirectoryNav(
|
|
188
|
+
generateDirectoryNav(directoryUrl, {
|
|
189
|
+
rootDirectoryUrl,
|
|
190
|
+
rootDirectoryUrlForServer:
|
|
191
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
192
|
+
}),
|
|
190
193
|
directoryContent: () => generateDirectoryContent(directoryContentItems),
|
|
191
194
|
};
|
|
192
195
|
const html = replacePlaceholders(htmlForDirectory, replacers);
|
|
@@ -216,47 +219,60 @@ const generateHtmlForENOENT = (
|
|
|
216
219
|
ancestorDirectoryUrl,
|
|
217
220
|
ancestorDirectoryRelativeUrl,
|
|
218
221
|
ancestorDirectoryNav: () =>
|
|
219
|
-
generateDirectoryNav(
|
|
222
|
+
generateDirectoryNav(ancestorDirectoryUrl, {
|
|
223
|
+
rootDirectoryUrl,
|
|
224
|
+
rootDirectoryUrlForServer:
|
|
225
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
226
|
+
}),
|
|
220
227
|
ancestorDirectoryContent: () =>
|
|
221
228
|
generateDirectoryContent(directoryContentItems),
|
|
222
229
|
};
|
|
223
230
|
const html = replacePlaceholders(htmlFor404AndAncestorDir, replacers);
|
|
224
231
|
return html;
|
|
225
232
|
};
|
|
226
|
-
const generateDirectoryNav = (
|
|
233
|
+
const generateDirectoryNav = (
|
|
234
|
+
entryDirectoryUrl,
|
|
235
|
+
{ rootDirectoryUrl, rootDirectoryUrlForServer },
|
|
236
|
+
) => {
|
|
237
|
+
const entryDirectoryRelativeUrl = urlToRelativeUrl(
|
|
238
|
+
entryDirectoryUrl,
|
|
239
|
+
rootDirectoryUrl,
|
|
240
|
+
);
|
|
241
|
+
const isDir = entryDirectoryRelativeUrl.endsWith("/");
|
|
227
242
|
const rootDirectoryUrlName = urlToFilename(rootDirectoryUrl);
|
|
228
|
-
const relativeUrlWithRoot = relativeUrl
|
|
229
|
-
? `${rootDirectoryUrlName}/${relativeUrl}`
|
|
230
|
-
: `${rootDirectoryUrlName}/`;
|
|
231
|
-
const isDir = relativeUrlWithRoot.endsWith("/");
|
|
232
|
-
const parts = isDir
|
|
233
|
-
? relativeUrlWithRoot.slice(0, -1).split("/")
|
|
234
|
-
: relativeUrlWithRoot.split("/");
|
|
235
243
|
const items = [];
|
|
236
|
-
items.push({
|
|
237
|
-
href: "/",
|
|
238
|
-
text: "/",
|
|
239
|
-
});
|
|
240
244
|
let dirPartsHtml = "";
|
|
245
|
+
const parts =
|
|
246
|
+
`${rootDirectoryUrlName}/${entryDirectoryRelativeUrl.slice(0, -1)}`.split(
|
|
247
|
+
"/",
|
|
248
|
+
);
|
|
241
249
|
let i = 0;
|
|
242
250
|
while (i < parts.length) {
|
|
243
251
|
const part = parts[i];
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
252
|
+
const directoryRelativeUrl = `${parts.slice(1, i + 1).join("/")}`;
|
|
253
|
+
const directoryUrl =
|
|
254
|
+
directoryRelativeUrl === ""
|
|
255
|
+
? rootDirectoryUrl
|
|
256
|
+
: new URL(`${directoryRelativeUrl}/`, rootDirectoryUrl).href;
|
|
257
|
+
let href =
|
|
258
|
+
directoryUrl === rootDirectoryUrlForServer ||
|
|
259
|
+
urlIsInsideOf(directoryUrl, rootDirectoryUrlForServer)
|
|
260
|
+
? urlToRelativeUrl(directoryUrl, rootDirectoryUrlForServer)
|
|
261
|
+
: directoryUrl;
|
|
262
|
+
if (href === "") {
|
|
263
|
+
href = `/${directoryContentMagicName}`;
|
|
264
|
+
}
|
|
248
265
|
const text = part;
|
|
249
|
-
const isLastPart = i === parts.length - 1;
|
|
250
266
|
items.push({
|
|
251
267
|
href,
|
|
252
268
|
text,
|
|
253
|
-
isCurrent: isLastPart,
|
|
254
269
|
});
|
|
255
270
|
i++;
|
|
256
271
|
}
|
|
257
272
|
i = 0;
|
|
258
|
-
for (const { href, text
|
|
259
|
-
|
|
273
|
+
for (const { href, text } of items) {
|
|
274
|
+
const isLastPart = i === parts.length - 1;
|
|
275
|
+
if (isLastPart) {
|
|
260
276
|
dirPartsHtml += `
|
|
261
277
|
<span class="directory_nav_item" data-current>
|
|
262
278
|
${text}
|
|
@@ -267,10 +283,8 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
267
283
|
<a class="directory_nav_item" href="${href}">
|
|
268
284
|
${text}
|
|
269
285
|
</a>`;
|
|
270
|
-
|
|
271
|
-
dirPartsHtml += `
|
|
286
|
+
dirPartsHtml += `
|
|
272
287
|
<span class="directory_separator">/</span>`;
|
|
273
|
-
}
|
|
274
288
|
i++;
|
|
275
289
|
}
|
|
276
290
|
if (isDir) {
|
|
@@ -279,12 +293,15 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
279
293
|
}
|
|
280
294
|
return dirPartsHtml;
|
|
281
295
|
};
|
|
282
|
-
const generateDirectoryContentItems = (
|
|
296
|
+
const generateDirectoryContentItems = (
|
|
297
|
+
directoryUrl,
|
|
298
|
+
rootDirectoryUrlForServer,
|
|
299
|
+
) => {
|
|
283
300
|
let firstExistingDirectoryUrl = new URL("./", directoryUrl);
|
|
284
301
|
while (!existsSync(firstExistingDirectoryUrl)) {
|
|
285
302
|
firstExistingDirectoryUrl = new URL("../", firstExistingDirectoryUrl);
|
|
286
|
-
if (!urlIsInsideOf(firstExistingDirectoryUrl,
|
|
287
|
-
firstExistingDirectoryUrl = new URL(
|
|
303
|
+
if (!urlIsInsideOf(firstExistingDirectoryUrl, rootDirectoryUrlForServer)) {
|
|
304
|
+
firstExistingDirectoryUrl = new URL(rootDirectoryUrlForServer);
|
|
288
305
|
break;
|
|
289
306
|
}
|
|
290
307
|
}
|
|
@@ -294,37 +311,42 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
294
311
|
const fileUrlObject = new URL(filename, firstExistingDirectoryUrl);
|
|
295
312
|
fileUrls.push(fileUrlObject);
|
|
296
313
|
}
|
|
314
|
+
let rootDirectoryUrl = rootDirectoryUrlForServer;
|
|
297
315
|
package_workspaces: {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const packageDirectoryUrl = lookupPackageDirectory(rootDirectoryUrl);
|
|
316
|
+
const packageDirectoryUrl = lookupPackageDirectory(
|
|
317
|
+
rootDirectoryUrlForServer,
|
|
318
|
+
);
|
|
302
319
|
if (!packageDirectoryUrl) {
|
|
303
320
|
break package_workspaces;
|
|
304
321
|
}
|
|
305
|
-
if (String(packageDirectoryUrl) === String(
|
|
322
|
+
if (String(packageDirectoryUrl) === String(rootDirectoryUrlForServer)) {
|
|
306
323
|
break package_workspaces;
|
|
307
324
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
rootDirectoryUrl = packageDirectoryUrl;
|
|
326
|
+
if (
|
|
327
|
+
String(firstExistingDirectoryUrl) === String(rootDirectoryUrlForServer)
|
|
328
|
+
) {
|
|
329
|
+
let packageContent;
|
|
330
|
+
try {
|
|
331
|
+
packageContent = JSON.parse(
|
|
332
|
+
readFileSync(new URL("package.json", packageDirectoryUrl), "utf8"),
|
|
333
|
+
);
|
|
334
|
+
} catch {
|
|
335
|
+
break package_workspaces;
|
|
336
|
+
}
|
|
337
|
+
const { workspaces } = packageContent;
|
|
338
|
+
if (Array.isArray(workspaces)) {
|
|
339
|
+
for (const workspace of workspaces) {
|
|
340
|
+
const workspaceUrlObject = new URL(workspace, packageDirectoryUrl);
|
|
341
|
+
const workspaceUrl = workspaceUrlObject.href;
|
|
342
|
+
if (workspaceUrl.endsWith("*")) {
|
|
343
|
+
const directoryUrl = ensurePathnameTrailingSlash(
|
|
344
|
+
workspaceUrl.slice(0, -1),
|
|
345
|
+
);
|
|
346
|
+
fileUrls.push(new URL(directoryUrl));
|
|
347
|
+
} else {
|
|
348
|
+
fileUrls.push(ensurePathnameTrailingSlash(workspaceUrlObject));
|
|
349
|
+
}
|
|
328
350
|
}
|
|
329
351
|
}
|
|
330
352
|
}
|
|
@@ -348,14 +370,18 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
348
370
|
sortedUrl,
|
|
349
371
|
firstExistingDirectoryUrl,
|
|
350
372
|
);
|
|
351
|
-
const
|
|
373
|
+
const fileUrlRelativeToServer = urlToRelativeUrl(
|
|
374
|
+
sortedUrl,
|
|
375
|
+
rootDirectoryUrlForServer,
|
|
376
|
+
);
|
|
352
377
|
const type = fileUrlRelativeToParent.endsWith("/") ? "dir" : "file";
|
|
353
378
|
items.push({
|
|
354
379
|
type,
|
|
355
380
|
fileUrlRelativeToParent,
|
|
356
|
-
|
|
381
|
+
fileUrlRelativeToServer,
|
|
357
382
|
});
|
|
358
383
|
}
|
|
384
|
+
items.rootDirectoryUrlForServer = rootDirectoryUrlForServer;
|
|
359
385
|
items.rootDirectoryUrl = rootDirectoryUrl;
|
|
360
386
|
items.firstExistingDirectoryUrl = firstExistingDirectoryUrl;
|
|
361
387
|
return items;
|
|
@@ -366,11 +392,15 @@ const generateDirectoryContent = (directoryContentItems) => {
|
|
|
366
392
|
}
|
|
367
393
|
let html = `<ul class="directory_content">`;
|
|
368
394
|
for (const directoryContentItem of directoryContentItems) {
|
|
369
|
-
const { type, fileUrlRelativeToParent,
|
|
395
|
+
const { type, fileUrlRelativeToParent, fileUrlRelativeToServer } =
|
|
370
396
|
directoryContentItem;
|
|
397
|
+
let href = fileUrlRelativeToServer;
|
|
398
|
+
if (href === "") {
|
|
399
|
+
href = `${directoryContentMagicName}`;
|
|
400
|
+
}
|
|
371
401
|
html += `
|
|
372
402
|
<li class="directory_child" data-type="${type}">
|
|
373
|
-
<a href="/${
|
|
403
|
+
<a href="/${href}">${fileUrlRelativeToParent}</a>
|
|
374
404
|
</li>`;
|
|
375
405
|
}
|
|
376
406
|
html += `\n </ul>`;
|