Skip to content

Commit

Permalink
Serve index.html when in app.asar
Browse files Browse the repository at this point in the history
Steps:
1. Set directory to be "." (e.g. serve from app.asar directly)
2. Bundle an electron app

Expected:
app://- serves index.html

Actual:
extname(".../app.asar") returns .asar, which fails the guard and serves
file not found.
  • Loading branch information
ibash committed Nov 5, 2020
1 parent 9636bee commit 6cedf4d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ module.exports = options => {
const indexPath = path.join(options.directory, 'index.html');
const filePath = path.join(options.directory, decodeURIComponent(new URL(request.url).pathname));
const resolvedPath = await getPath(filePath);
const extname = path.extname(filePath);

if (resolvedPath || !path.extname(filePath) || path.extname(filePath) === '.html') {
if (resolvedPath || !extname || extname === '.html' || extname === '.asar') {
callback({
path: resolvedPath || indexPath
});
Expand Down

0 comments on commit 6cedf4d

Please sign in to comment.