vite-plugin-files-server 1.0.1 → 1.0.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/index.cjs CHANGED
@@ -368,6 +368,9 @@ function fileServerPlugin(options = {}) {
368
368
  if (!enable) return;
369
369
  server.middlewares.use((req, res, next) => {
370
370
  const url = req.url ? decodeURIComponent(req.url.split("?")[0]) : "/";
371
+ if (url.startsWith("/@") || url.includes("vite")) {
372
+ return next();
373
+ }
371
374
  const projectRoot = server.config.root;
372
375
  const fullPath = import_path.default.join(projectRoot, url);
373
376
  try {
@@ -387,19 +390,19 @@ function fileServerPlugin(options = {}) {
387
390
  const isDir = import_fs.default.statSync(filePath).isDirectory();
388
391
  const href = import_path.default.join(url, file).replace(/\\/g, "/");
389
392
  const item = `
390
- <li>
391
- <a href="${href}" class="icon ${isDir ? "icon-directory" : "icon-html icon-text-html"}">
392
- <span class="name">${file}</span>
393
- </a>
394
- </li>`;
393
+ <li>
394
+ <a href="${href}" class="icon ${isDir ? "icon-directory" : "icon-html icon-text-html"}">
395
+ <span class="name">${file}</span>
396
+ </a>
397
+ </li>`;
395
398
  return item;
396
399
  }).join("");
397
400
  urlSplitArray = urlSplitArray.slice(0, -1);
398
401
  let backUrl = urlSplitArray.join("/");
399
402
  const backItem = `
400
- <li>
401
- <a href="${backUrl}" class="icon icon-directory"><span class="name">..</span></a>
402
- </li>`;
403
+ <li>
404
+ <a href="${backUrl}" class="icon icon-directory"><span class="name">..</span></a>
405
+ </li>`;
403
406
  let fullList = urlSplitArray.length > 1 ? backItem + listItems : listItems;
404
407
  const html = temp_default.replace(/{{title}}/g, `Index of ${url}`).replace(/{{headItem}}/g, headItem).replace(/{{url}}/g, url).replace(/{{listItems}}/g, fullList);
405
408
  res.setHeader("Content-Type", "text/html");
package/dist/index.js CHANGED
@@ -334,6 +334,9 @@ function fileServerPlugin(options = {}) {
334
334
  if (!enable) return;
335
335
  server.middlewares.use((req, res, next) => {
336
336
  const url = req.url ? decodeURIComponent(req.url.split("?")[0]) : "/";
337
+ if (url.startsWith("/@") || url.includes("vite")) {
338
+ return next();
339
+ }
337
340
  const projectRoot = server.config.root;
338
341
  const fullPath = path.join(projectRoot, url);
339
342
  try {
@@ -353,19 +356,19 @@ function fileServerPlugin(options = {}) {
353
356
  const isDir = fs.statSync(filePath).isDirectory();
354
357
  const href = path.join(url, file).replace(/\\/g, "/");
355
358
  const item = `
356
- <li>
357
- <a href="${href}" class="icon ${isDir ? "icon-directory" : "icon-html icon-text-html"}">
358
- <span class="name">${file}</span>
359
- </a>
360
- </li>`;
359
+ <li>
360
+ <a href="${href}" class="icon ${isDir ? "icon-directory" : "icon-html icon-text-html"}">
361
+ <span class="name">${file}</span>
362
+ </a>
363
+ </li>`;
361
364
  return item;
362
365
  }).join("");
363
366
  urlSplitArray = urlSplitArray.slice(0, -1);
364
367
  let backUrl = urlSplitArray.join("/");
365
368
  const backItem = `
366
- <li>
367
- <a href="${backUrl}" class="icon icon-directory"><span class="name">..</span></a>
368
- </li>`;
369
+ <li>
370
+ <a href="${backUrl}" class="icon icon-directory"><span class="name">..</span></a>
371
+ </li>`;
369
372
  let fullList = urlSplitArray.length > 1 ? backItem + listItems : listItems;
370
373
  const html = temp_default.replace(/{{title}}/g, `Index of ${url}`).replace(/{{headItem}}/g, headItem).replace(/{{url}}/g, url).replace(/{{listItems}}/g, fullList);
371
374
  res.setHeader("Content-Type", "text/html");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-files-server",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",