diff --git a/src/utils/getFilePath.js b/src/utils/getFilePath.js index 42dd22e..1316f63 100644 --- a/src/utils/getFilePath.js +++ b/src/utils/getFilePath.js @@ -3,14 +3,15 @@ import { options } from '../index.js'; export const getFilePath = request => { const { root } = options; + const url = new URL(request.url, `http://${request.headers.host}`); - if (request.url == '/') return `${root}/index.html`; + if (url.pathname == '/') return `${root}/index.html`; - if (!request.url.includes('.')) { - const testFilepath = `${root}/${request.url}.html`; + if (!url.pathname.includes('.')) { + const testFilepath = `${root}/${url.pathname}.html`; if (fs.existsSync(testFilepath)) return testFilepath; } - return root + request.url; + return root + url.pathname; };