Skip to content

Commit

Permalink
fix(dev-server): remove forward slashes and fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
tbhowmik2 committed Oct 31, 2023
1 parent a408124 commit e8d1608
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/reporters/dev-server/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export default class Server {
// Extract the pathname from the url
const URLpathname = req.url.split('?')[0];

// Remove forward slashes - '/some/path/' to '/some/path'
const cleanedURLpathname = URLpathname.replace(/\/+$/, '');

indexFilePath = htmlBundleFilePaths
// Sorting for multiple html file paths for url '/some/path'
// Order ['some/path.html', '/some/path/index.html']
Expand Down Expand Up @@ -228,22 +231,22 @@ export default class Server {
basenameWithoutExtenion,
);

// Matching possiblities
// Matching possibilities
// 1: /some/path(url path) -> /some/path.html(file path)
// 2: /some/path.html(url path) -> /some/path.html(file path)
if (
URLpathname === filePathWithoutExtension ||
URLpathname === filePath
cleanedURLpathname === filePathWithoutExtension ||
cleanedURLpathname === filePath
) {
return true;
}

const isIndex = basenameWithoutExtenion === 'index';

// Matching index possiblities
// Matching index possibilities
// 1: /some/path(url path) -> /some/path/index.html(file path)
if (isIndex) {
return URLpathname === baseDir;
return cleanedURLpathname === baseDir;
}

return false;
Expand Down

0 comments on commit e8d1608

Please sign in to comment.