Skip to content

Commit 8645538

Browse files
author
Andrea Cosentino
committed
fix: normalize paths
1 parent be5c991 commit 8645538

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/utils/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ export const Utils = {
4949
},
5050
initOptions(opts: UniversalApiOptions | undefined, config: ResolvedConfig): UniversalApiOptionsRequired {
5151
const fullFsDir = join(config.root, opts?.fsDir ?? "");
52+
const normalizePrefix = (el: string): string => {
53+
let endpoint = Utils.request.addSlash(el, "leading");
54+
endpoint = Utils.request.removeSlash(endpoint, "trailing");
55+
return endpoint;
56+
};
5257
const endpointPrefix = opts?.endpointPrefix
5358
? Array.isArray(opts.endpointPrefix) && opts.endpointPrefix.length > 0
54-
? opts.endpointPrefix.map(el => {
55-
let endpoint = Utils.request.addSlash(el, "leading");
56-
endpoint = Utils.request.removeSlash(endpoint, "trailing");
57-
return endpoint;
58-
})
59-
: Array.isArray(opts.endpointPrefix) ? opts.endpointPrefix : [opts.endpointPrefix]
59+
? opts.endpointPrefix.map(normalizePrefix)
60+
: Array.isArray(opts.endpointPrefix) ? opts.endpointPrefix : [normalizePrefix(opts.endpointPrefix)]
6061
: ['/api'];
6162
return {
6263
disable: opts?.disable ?? false,

0 commit comments

Comments
 (0)