1
1
diff --git a/build.js b/build.js
2
- index 0c6ed8e2c0949c93978dd1a244baa9bf2448e9b8..08a9347cfdca06e6a97077ea4582c5b0922ecb2d 100644
2
+ index 3734120d67745ff83b2df07fa5d0a40dcb92a69b..bd57f693ac2bd4555a12e7a5436fb9524789ef66 100644
3
3
--- a/build.js
4
4
+++ b/build.js
5
5
@@ -35,7 +35,7 @@ function viaCache(cache, uri, extns) {
@@ -11,15 +11,24 @@ index 0c6ed8e2c0949c93978dd1a244baa9bf2448e9b8..08a9347cfdca06e6a97077ea4582c5b0
11
11
let i=0, arr=toAssume(uri, extns);
12
12
let abs, stats, name, headers;
13
13
for (; i < arr.length; i++) {
14
- @@ -43 ,6 +43 ,7 @@ function viaLocal(dir, isEtag, uri, extns) {
14
+ @@ -46 ,6 +46 ,7 @@ function viaLocal(dir, isEtag, uri, extns) {
15
15
if (abs.startsWith(dir) && fs.existsSync(abs)) {
16
16
stats = fs.statSync(abs);
17
17
if (stats.isDirectory()) continue;
18
18
+ if (shouldServe && !shouldServe(abs)) continue;
19
19
headers = toHeaders(name, stats, isEtag);
20
20
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
21
21
return { abs, stats, headers };
22
- @@ -176,7 +177,7 @@ module.exports = function (dir, opts={}) {
22
+ @@ -164,7 +165,7 @@ module.exports = function (dir, opts={}) {
23
+ });
24
+ }
25
+
26
+ - let lookup = opts.dev ? viaLocal.bind(0, dir + sep, isEtag) : viaCache.bind(0, FILES);
27
+ + let lookup = opts.dev ? viaLocal.bind(0, dir.endsWith(sep) ? dir : dir + sep, isEtag) : viaCache.bind(0, FILES);
28
+
29
+ return function (req, res, next) {
30
+ let extns = [''];
31
+ @@ -179,7 +180,7 @@ module.exports = function (dir, opts={}) {
23
32
catch (err) { /* malform uri */ }
24
33
}
25
34
@@ -29,7 +38,7 @@ index 0c6ed8e2c0949c93978dd1a244baa9bf2448e9b8..08a9347cfdca06e6a97077ea4582c5b0
29
38
30
39
if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
31
40
diff --git a/build.mjs b/build.mjs
32
- index 3ad14d45630a8627b93842a04a96465120d3f223..8451277c015b56a7d2cb99aaee3a318d9c0893dd 100644
41
+ index 2f866d5216c951ec125f2044af070fa6b530e375..d5335bfbb16e23b57385c1a83226611e29c39093 100644
33
42
--- a/build.mjs
34
43
+++ b/build.mjs
35
44
@@ -35,7 +35,7 @@ function viaCache(cache, uri, extns) {
@@ -41,15 +50,24 @@ index 3ad14d45630a8627b93842a04a96465120d3f223..8451277c015b56a7d2cb99aaee3a318d
41
50
let i=0, arr=toAssume(uri, extns);
42
51
let abs, stats, name, headers;
43
52
for (; i < arr.length; i++) {
44
- @@ -43 ,6 +43 ,7 @@ function viaLocal(dir, isEtag, uri, extns) {
53
+ @@ -46 ,6 +46 ,7 @@ function viaLocal(dir, isEtag, uri, extns) {
45
54
if (abs.startsWith(dir) && fs.existsSync(abs)) {
46
55
stats = fs.statSync(abs);
47
56
if (stats.isDirectory()) continue;
48
57
+ if (shouldServe && !shouldServe(abs)) continue;
49
58
headers = toHeaders(name, stats, isEtag);
50
59
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
51
60
return { abs, stats, headers };
52
- @@ -176,7 +177,7 @@ export default function (dir, opts={}) {
61
+ @@ -164,7 +165,7 @@ export default function (dir, opts={}) {
62
+ });
63
+ }
64
+
65
+ - let lookup = opts.dev ? viaLocal.bind(0, dir + sep, isEtag) : viaCache.bind(0, FILES);
66
+ + let lookup = opts.dev ? viaLocal.bind(0, dir.endsWith(sep) ? dir : dir + sep, isEtag) : viaCache.bind(0, FILES);
67
+
68
+ return function (req, res, next) {
69
+ let extns = [''];
70
+ @@ -179,7 +180,7 @@ export default function (dir, opts={}) {
53
71
catch (err) { /* malform uri */ }
54
72
}
55
73
0 commit comments