From dd14c01f6fcded538bff89e2845caad0e9745912 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 11 Aug 2022 10:48:14 +0100 Subject: [PATCH] fix(resolve): always try to resolve url as dir too (#67) --- src/resolve.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/resolve.ts b/src/resolve.ts index 0cc0cb4..e444d9f 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -57,14 +57,11 @@ function _resolve (id: string, opts: ResolveOptions = {}): string { _urls.push(DEFAULT_URL) } const urls = [..._urls] - for (let url of _urls) { + for (const url of _urls) { if (url.protocol === 'file:') { - if (!url.pathname.match(/[^/]+\.[^/.]+$/)) { - // URL does not ends with extension. It is probably a directory. - url = new URL(url) - url.pathname = joinURL(url.pathname, '_index.js') - } urls.push(new URL('./', url)) + // If url is directory + urls.push(new URL(joinURL(url.pathname, '_index.js'), url)) // TODO: Remove in next major version seems not necessary urls.push(new URL('./node_modules', url)) }