fix: better handling of .spa file being in the root, improved code
path
This commit is contained in:
parent
474d455986
commit
1220f1a370
3 changed files with 11 additions and 15 deletions
|
|
@ -13,11 +13,7 @@ async function find_spa_file_root(request_path: string): Promise<string | undefi
|
|||
const relative_path = path.relative(current_path, request_path);
|
||||
const path_elements = relative_path.split('/').slice(0, -1);
|
||||
|
||||
let element;
|
||||
|
||||
while ((element = path_elements.shift())) {
|
||||
current_path = path.join(current_path, element);
|
||||
|
||||
do {
|
||||
try {
|
||||
const spa_file_stat = await Deno.stat(path.join(current_path, '.spa'));
|
||||
|
||||
|
|
@ -25,13 +21,13 @@ async function find_spa_file_root(request_path: string): Promise<string | undefi
|
|||
return current_path;
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Deno.errors.NotFound) {
|
||||
continue;
|
||||
if (!(error instanceof Deno.errors.NotFound)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
current_path = path.join(current_path, path_elements.shift() ?? '');
|
||||
} while (path_elements.length);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue