Skip to content

Commit f7c6f5c

Browse files
committed
Updated asset paths to work with stripFromPath
1 parent 3a03600 commit f7c6f5c

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ module.exports = (http) => {
111111
}
112112
else {
113113
if (this.assetPaths.hasOwnProperty(fileType) && this.assetPaths[fileType].hasOwnProperty('path')) {
114-
const { path } = this.assetPaths[file];
115-
file = path.replace(`${assetType}/`, '');
114+
const { path: filePath } = this.assetPaths[file];
115+
file = filePath.replace(`${assetType}/`, '');
116116
}
117117

118-
this.renderAsset(path, file, path, res);
118+
this.renderAsset(assetType, file, assetType, res);
119119
}
120120
}
121121
else {
@@ -199,10 +199,13 @@ module.exports = (http) => {
199199
* @param string stripFromPath
200200
*/
201201
renderAsset(path, file, assetType, res, stripFromPath) {
202-
fs.readFile(`${path}${file}`.replace(stripFromPath, ''), (err, data) => {
202+
const filePath = `${path}${file}`.replace(stripFromPath, '');
203+
204+
fs.readFile(filePath, (err, data) => {
203205
if (err) {
206+
console.error(err);
204207
res.statusCode = 404;
205-
res.end(`File ${path}/${file} doesn't exist`);
208+
res.end(`File ${filePath} doesn't exist`);
206209
}
207210

208211
if (assetType == 'js') {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "small-router",
3-
"version": "1.1.5",
3+
"version": "1.1.10",
44
"description": "Small router module that creates http server and runs callbacks that have have been added for a route via the api",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)