@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 +5 -5
- package/dist/run.cjs +5 -5
- package/dist/run.mjs +5 -5
- package/package.json +1 -1
- package/src/getFilePath.ts +5 -8
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(
|
|
50
|
-
let
|
|
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,
|
|
54
|
-
if (!
|
|
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,
|
|
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(
|
|
33
|
-
let
|
|
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,
|
|
37
|
-
if (!
|
|
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,
|
|
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(
|
|
32
|
-
let
|
|
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,
|
|
36
|
-
if (!
|
|
35
|
+
let filePath = join(dirPath, urlPath);
|
|
36
|
+
if (!urlPath.endsWith("/") && await isValidFilePath(filePath, dirPath))
|
|
37
37
|
return filePath;
|
|
38
|
-
filePath = join(dirPath,
|
|
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
package/src/getFilePath.ts
CHANGED
|
@@ -5,22 +5,19 @@ import { isValidFilePath } from "./isValidFilePath";
|
|
|
5
5
|
const cwd = process.cwd();
|
|
6
6
|
|
|
7
7
|
export async function getFilePath(
|
|
8
|
-
|
|
8
|
+
url = "",
|
|
9
9
|
{ path = "", dirs = [], spa }: Config,
|
|
10
10
|
) {
|
|
11
|
-
let
|
|
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,
|
|
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,
|
|
20
|
+
filePath = join(dirPath, spa ? "" : urlPath, "index.html");
|
|
24
21
|
|
|
25
22
|
if (await isValidFilePath(filePath, dirPath)) return filePath;
|
|
26
23
|
}
|