Use posix normaliser for URL paths

Signed-off-by: Gabriele Mambrini <gabriele.mambrini@jimdo.com>
This commit is contained in:
Gabriele Mambrini
2021-11-08 18:06:53 +01:00
parent 0514f55ff1
commit f14ac64f2e
@@ -24,7 +24,7 @@ import {
SearchResponse,
UrlReader,
} from './types';
import { normalize as normalizePath } from 'path';
import path from 'path';
/**
* A UrlReader that does a plain fetch of the URL.
@@ -52,8 +52,10 @@ export class FetchUrlReader implements UrlReader {
const paths = allowConfig.getOptionalStringArray('paths');
const checkPath = paths
? (url: URL) => {
const targetPath = normalizePath(url.pathname);
return paths.some(path => targetPath.startsWith(path));
const targetPath = path.posix.normalize(url.pathname);
return paths.some(allowedPath =>
targetPath.startsWith(allowedPath),
);
}
: (_url: URL) => true;
const host = allowConfig.getString('host');