From 2be2adbfb1bde578898cd4fa4707e29c90b43254 Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Sat, 11 Feb 2023 02:03:44 -0500 Subject: [PATCH] fix(utils): [`fillModules`] `dot.case` specifier support Signed-off-by: Lexus Drumgold --- src/utils/fill-modules.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/utils/fill-modules.ts b/src/utils/fill-modules.ts index ef4599de..285dd718 100644 --- a/src/utils/fill-modules.ts +++ b/src/utils/fill-modules.ts @@ -8,8 +8,7 @@ import type { FillModuleOptions } from '#src/interfaces' import regexp from '#src/internal/escape-reg-exp' import isFunction from '#src/internal/is-function' import { ERR_UNKNOWN_FILE_EXTENSION } from '@flex-development/errnode' -import pathe, { type Ext } from '@flex-development/pathe' -import type { EmptyString } from '@flex-development/tutils' +import pathe from '@flex-development/pathe' import type { URL } from 'node:url' import CONDITIONS from './conditions' import extractStatements from './extract-statements' @@ -72,15 +71,11 @@ const fillModules = async ( * @return {Promise} New file extension or `undefined` */ async ext(specifier: string, url: URL): Promise { - /** - * Current file extension of {@linkcode specifier}. - * - * @const {EmptyString | Ext} extname - */ - const extname: EmptyString | Ext = pathe.extname(specifier) + // skip replacement for bare specifiers + if (isBareSpecifier(specifier)) return void 0 - // skip replacement for bare and already fully specified specifiers - if (isBareSpecifier(specifier) || extname.length > 1) return undefined + // skip replacement for specifiers that are already fully specified + if (pathe.extname(specifier) === pathe.extname(url.href)) return void 0 /** * Replacement file extension.