spa-ssi 0.0.3 → 0.0.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/serve.js +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spa-ssi",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Single Page App / Server Side Include Simple File Web Server",
5
5
  "keywords": [
6
6
  "single-page-app",
package/serve.js CHANGED
@@ -76,7 +76,7 @@ class SimpleHTTPRequestHandler {
76
76
 
77
77
  } catch (err) {
78
78
  res.writeHead(404, { "Content-Type": "text/plain" });
79
- res.end("404 Not Found\n");
79
+ res.end(`404 Not Found: ${JSON.stringify(err, null, 2)} \n`);
80
80
  }
81
81
  }
82
82
 
@@ -191,7 +191,8 @@ class SimpleHTTPRequestHandler {
191
191
  const tasks = [];
192
192
  let match;
193
193
  while ((match = includeRegex.exec(html)) !== null) {
194
- const includePath = path.join(currentDir, match[1]);
194
+ const includeString = match[1];
195
+ const includePath = includeString.startsWith('/') ? path.join(process.cwd(), includeString) : path.join(currentDir, includeString);
195
196
  const content = await fs.readFile(includePath, 'utf8');
196
197
  html = html.replace(match[0], content);
197
198