Skip to content

Commit f6fc63a

Browse files
committed
Fix static file lookup logic
1 parent 73203db commit f6fc63a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

assets/lambda-package/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,36 @@ var app = new FastBoot({ distPath: distPath });
6161

6262
var serveACheekyFile = (path, staticPath, fileBuffer) => {
6363
// 1. Early exit bail
64-
var isAssetValidPath = validAssetPaths.find(p => p.includes(path));
64+
var isAssetValidPath = validAssetPaths.find(p => path.includes(p));
65+
console.log('INFO validAssetPaths:', validAssetPaths);
6566
console.log('INFO isAssetValidPath:', isAssetValidPath);
6667
if (!isAssetValidPath) { throw true; }
6768

68-
// 1. Look up files content type.
69+
// 2. Look up files content type.
6970
var contentType = mime.lookup(staticPath);
7071

71-
//2. Get file extension.
72+
//3. Get file extension.
7273
var extension = mime.extension(contentType);
7374

74-
//3. If it isn't a standard file, then base64 encode it.
75+
//4. If it isn't a standard file, then base64 encode it.
7576
var shouldEncode = stringyExtensions.indexOf(extension) < 0;
7677

77-
//4. Determine if the item is fingerprinted/cacheable
78+
//5. Determine if the item is fingerprinted/cacheable
7879
var shouldCache = staticPath.includes(defaults.assetsPath);
7980

80-
//5. Set encoding value
81+
//6. Set encoding value
8182
var encoding = shouldEncode ? 'base64' : 'utf8';
8283

83-
//6. Create headers
84+
//7. Create headers
8485
var headers = {
8586
'Content-Type': contentType,
8687
'Cache-Control': shouldCache ? fancyACacheYeh.yes : fancyACacheYeh.no
8788
};
8889

89-
//7. Create body
90+
//8. Create body
9091
var body = fileBuffer.toString(encoding);
9192

92-
//8. Create final output
93+
//9. Create final output
9394
var payload = {
9495
statusCode: 200,
9596
headers: headers,

0 commit comments

Comments
 (0)