@t8/serve 0.1.7 → 0.1.8

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.js CHANGED
@@ -46,14 +46,14 @@ async function isValidFilePath(filePath, dirPath) {
46
46
 
47
47
  // src/getFilePath.ts
48
48
  var cwd = process.cwd();
49
- async function getFilePath(urlPath = "", { path = "", dirs = [], spa }) {
50
- let effectiveURLPath = spa ? "/" : urlPath.replace(/[?#].*$/, "");
49
+ async function getFilePath(url = "", { path = "", dirs = [], spa }) {
50
+ let urlPath = url.replace(/[?#].*$/, "");
51
51
  for (let dir of dirs.length === 0 ? [""] : dirs) {
52
52
  let dirPath = (0, import_node_path.join)(cwd, path, dir);
53
- let filePath = (0, import_node_path.join)(dirPath, effectiveURLPath);
54
- if (!effectiveURLPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
53
+ let filePath = (0, import_node_path.join)(dirPath, urlPath);
54
+ if (!urlPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
55
55
  return filePath;
56
- filePath = (0, import_node_path.join)(dirPath, effectiveURLPath, "index.html");
56
+ filePath = (0, import_node_path.join)(dirPath, spa ? "" : urlPath, "index.html");
57
57
  if (await isValidFilePath(filePath, dirPath)) return filePath;
58
58
  }
59
59
  }
package/dist/run.cjs CHANGED
@@ -29,14 +29,14 @@ async function isValidFilePath(filePath, dirPath) {
29
29
 
30
30
  // src/getFilePath.ts
31
31
  var cwd = process.cwd();
32
- async function getFilePath(urlPath = "", { path = "", dirs = [], spa }) {
33
- let effectiveURLPath = spa ? "/" : urlPath.replace(/[?#].*$/, "");
32
+ async function getFilePath(url = "", { path = "", dirs = [], spa }) {
33
+ let urlPath = url.replace(/[?#].*$/, "");
34
34
  for (let dir of dirs.length === 0 ? [""] : dirs) {
35
35
  let dirPath = (0, import_node_path.join)(cwd, path, dir);
36
- let filePath = (0, import_node_path.join)(dirPath, effectiveURLPath);
37
- if (!effectiveURLPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
36
+ let filePath = (0, import_node_path.join)(dirPath, urlPath);
37
+ if (!urlPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
38
38
  return filePath;
39
- filePath = (0, import_node_path.join)(dirPath, effectiveURLPath, "index.html");
39
+ filePath = (0, import_node_path.join)(dirPath, spa ? "" : urlPath, "index.html");
40
40
  if (await isValidFilePath(filePath, dirPath)) return filePath;
41
41
  }
42
42
  }
package/dist/run.mjs CHANGED
@@ -28,14 +28,14 @@ async function isValidFilePath(filePath, dirPath) {
28
28
 
29
29
  // src/getFilePath.ts
30
30
  var cwd = process.cwd();
31
- async function getFilePath(urlPath = "", { path = "", dirs = [], spa }) {
32
- let effectiveURLPath = spa ? "/" : urlPath.replace(/[?#].*$/, "");
31
+ async function getFilePath(url = "", { path = "", dirs = [], spa }) {
32
+ let urlPath = url.replace(/[?#].*$/, "");
33
33
  for (let dir of dirs.length === 0 ? [""] : dirs) {
34
34
  let dirPath = join(cwd, path, dir);
35
- let filePath = join(dirPath, effectiveURLPath);
36
- if (!effectiveURLPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
35
+ let filePath = join(dirPath, urlPath);
36
+ if (!urlPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
37
37
  return filePath;
38
- filePath = join(dirPath, effectiveURLPath, "index.html");
38
+ filePath = join(dirPath, spa ? "" : urlPath, "index.html");
39
39
  if (await isValidFilePath(filePath, dirPath)) return filePath;
40
40
  }
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/serve",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "node",
@@ -5,22 +5,19 @@ import { isValidFilePath } from "./isValidFilePath";
5
5
  const cwd = process.cwd();
6
6
 
7
7
  export async function getFilePath(
8
- urlPath = "",
8
+ url = "",
9
9
  { path = "", dirs = [], spa }: Config,
10
10
  ) {
11
- let effectiveURLPath = spa ? "/" : urlPath.replace(/[?#].*$/, "");
11
+ let urlPath = url.replace(/[?#].*$/, "");
12
12
 
13
13
  for (let dir of dirs.length === 0 ? [""] : dirs) {
14
14
  let dirPath = join(cwd, path, dir);
15
- let filePath = join(dirPath, effectiveURLPath);
15
+ let filePath = join(dirPath, urlPath);
16
16
 
17
- if (
18
- !effectiveURLPath.endsWith("/") &&
19
- (await isValidFilePath(filePath, dirPath))
20
- )
17
+ if (!urlPath.endsWith("/") && (await isValidFilePath(filePath, dirPath)))
21
18
  return filePath;
22
19
 
23
- filePath = join(dirPath, effectiveURLPath, "index.html");
20
+ filePath = join(dirPath, spa ? "" : urlPath, "index.html");
24
21
 
25
22
  if (await isValidFilePath(filePath, dirPath)) return filePath;
26
23
  }