From a647df8c8bf367490b7b5c9a112655b6eb9b9c54 Mon Sep 17 00:00:00 2001 From: Nikita Rykov <40735471+angrymouse@users.noreply.github.com> Date: Fri, 21 Oct 2022 06:02:04 +0300 Subject: [PATCH 1/4] Proper support for index.html Right now, if there's folder /app/ and file index.html in it (/app/index.html), then if I go to /app/ then I will get 404 error (while /app/index.html works). Many SSG frameworks use it as standard to build sites, and it's common to have index.html served to root. --- src/lib/deploy.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/deploy.ts b/src/lib/deploy.ts index ec7dfe7..c9adf05 100644 --- a/src/lib/deploy.ts +++ b/src/lib/deploy.ts @@ -412,6 +412,20 @@ export default class Deploy { useBundler: string, feeMultiplier: number, ) { + this.duplicates.forEach(duplicate=>{ + + if(duplicate.filePath.endsWith("/index.html")){ + duplicate.filePath=duplicate.filePath.slice(-("index.html").length) + this.duplicates.push(duplicate) + } + }) + this.txs.forEach(txD=>{ + + if(txD.filePath.endsWith("/index.html")){ + txD.filePath=txD.filePath.slice(-("index.html").length) + this.txs.push(txD) + } + }) const { results: pDuplicates } = await PromisePool.for(this.duplicates) .withConcurrency(this.threads) .process(async (txD) => { From 38b3c2a449fe321ec5a2b30eee509370c00e92e8 Mon Sep 17 00:00:00 2001 From: Nikita Rykov <40735471+angrymouse@users.noreply.github.com> Date: Fri, 21 Oct 2022 06:37:40 +0300 Subject: [PATCH 2/4] Little fix --- src/lib/deploy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/deploy.ts b/src/lib/deploy.ts index c9adf05..088ffdf 100644 --- a/src/lib/deploy.ts +++ b/src/lib/deploy.ts @@ -415,14 +415,14 @@ export default class Deploy { this.duplicates.forEach(duplicate=>{ if(duplicate.filePath.endsWith("/index.html")){ - duplicate.filePath=duplicate.filePath.slice(-("index.html").length) + duplicate.filePath=duplicate.filePath.slice(0,-(("index.html").length)) this.duplicates.push(duplicate) } }) this.txs.forEach(txD=>{ if(txD.filePath.endsWith("/index.html")){ - txD.filePath=txD.filePath.slice(-("index.html").length) + txD.filePath=txD.filePath.slice(0,-(("index.html").length)) this.txs.push(txD) } }) From ec9d2fa0ca93dfbf3304f7f40ddf729a8d9604dd Mon Sep 17 00:00:00 2001 From: Nikita Rykov <40735471+angrymouse@users.noreply.github.com> Date: Fri, 21 Oct 2022 06:52:33 +0300 Subject: [PATCH 3/4] Fix --- src/lib/deploy.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/deploy.ts b/src/lib/deploy.ts index 088ffdf..cf8c586 100644 --- a/src/lib/deploy.ts +++ b/src/lib/deploy.ts @@ -415,15 +415,17 @@ export default class Deploy { this.duplicates.forEach(duplicate=>{ if(duplicate.filePath.endsWith("/index.html")){ - duplicate.filePath=duplicate.filePath.slice(0,-(("index.html").length)) - this.duplicates.push(duplicate) + let rootPath={...duplicate,filePath:duplicate.filePath.slice(0,-(("/index.html").length)} + + this.duplicates.push(rootPath) } }) this.txs.forEach(txD=>{ if(txD.filePath.endsWith("/index.html")){ - txD.filePath=txD.filePath.slice(0,-(("index.html").length)) - this.txs.push(txD) + let rootPath={...txD,filePath:txD.filePath.slice(0,-(("/index.html").length)} + + this.txs.push(rootPath) } }) const { results: pDuplicates } = await PromisePool.for(this.duplicates) From 56af41313ff16adaea67c018dd1c9976eaca235f Mon Sep 17 00:00:00 2001 From: Nikita Rykov <40735471+angrymouse@users.noreply.github.com> Date: Fri, 21 Oct 2022 06:55:17 +0300 Subject: [PATCH 4/4] ) --- src/lib/deploy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/deploy.ts b/src/lib/deploy.ts index cf8c586..47135ad 100644 --- a/src/lib/deploy.ts +++ b/src/lib/deploy.ts @@ -415,7 +415,7 @@ export default class Deploy { this.duplicates.forEach(duplicate=>{ if(duplicate.filePath.endsWith("/index.html")){ - let rootPath={...duplicate,filePath:duplicate.filePath.slice(0,-(("/index.html").length)} + let rootPath={...duplicate,filePath:duplicate.filePath.slice(0,-(("/index.html").length))} this.duplicates.push(rootPath) } @@ -423,7 +423,7 @@ export default class Deploy { this.txs.forEach(txD=>{ if(txD.filePath.endsWith("/index.html")){ - let rootPath={...txD,filePath:txD.filePath.slice(0,-(("/index.html").length)} + let rootPath={...txD,filePath:txD.filePath.slice(0,-(("/index.html").length))} this.txs.push(rootPath) }