mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
fix(javascript): resolve proven URL constructor aliases
Remove the redundant spelling gate after the shared intrinsic owner proves native constructor and source-base identity. Retain local-constructor and replaced-export uncertainty through public application analysis.
This commit is contained in:
@@ -267,12 +267,6 @@ export interface JavaScriptStaticSourceUrlPath {
|
||||
readonly directory: boolean;
|
||||
}
|
||||
|
||||
/** Read a literal `new URL(relative, import.meta.url)` shape without evaluation. */
|
||||
export const staticSourceRelativeUrlPath = (
|
||||
node: t.Node,
|
||||
): JavaScriptStaticSourceUrlPath | undefined =>
|
||||
isSourceFileUrl(node) ? sourceRelativeFileUrlPath(node) : undefined;
|
||||
|
||||
/** Convert an exact static file URL expression to a POSIX path. */
|
||||
export const staticFileUrlPath = (
|
||||
node: t.CallExpression | t.NewExpression,
|
||||
@@ -282,8 +276,8 @@ export const staticFileUrlPath = (
|
||||
const rawArgument = argumentNode(node.arguments[0]);
|
||||
if (rawArgument === undefined) return undefined;
|
||||
const argument = unwrapJavaScriptExpression(rawArgument).node;
|
||||
if (isSourceFileUrl(argument) && pathIntrinsics?.(argument, "source-url"))
|
||||
return sourceRelativeFileUrlPath(argument)?.path;
|
||||
if (t.isNewExpression(argument) && pathIntrinsics?.(argument, "source-url"))
|
||||
return staticSourceRelativeUrlPath(argument)?.path;
|
||||
const value = staticPath(argument, pathIntrinsics);
|
||||
const rawPath = value?.split(/[?#]/u, 1)[0] ?? "";
|
||||
if (
|
||||
@@ -308,9 +302,9 @@ export const staticFileUrlPath = (
|
||||
}
|
||||
};
|
||||
|
||||
/** Project a known source-relative URL through the actual file URL decoder. */
|
||||
const sourceRelativeFileUrlPath = (
|
||||
node: t.CallExpression | t.NewExpression,
|
||||
/** Decode a source-relative URL after the caller proves constructor and base identity. */
|
||||
export const staticSourceRelativeUrlPath = (
|
||||
node: t.NewExpression,
|
||||
): JavaScriptStaticSourceUrlPath | undefined => {
|
||||
const value = stringValue(node.arguments[0]);
|
||||
if (
|
||||
@@ -350,14 +344,6 @@ const sourceRelativeFileUrlPath = (
|
||||
}
|
||||
};
|
||||
|
||||
const isSourceFileUrl = (
|
||||
node: t.Node,
|
||||
): node is t.CallExpression | t.NewExpression =>
|
||||
(t.isCallExpression(node) || t.isNewExpression(node)) &&
|
||||
(calleeName(node.callee) === "URL" ||
|
||||
calleeName(node.callee).endsWith(".URL")) &&
|
||||
isFileIdentity(argumentNode(node.arguments[1]));
|
||||
|
||||
const staticResolvedPath = (
|
||||
node: t.CallExpression | t.NewExpression,
|
||||
pathIntrinsics?: JavaScriptStaticPathIntrinsicQuery,
|
||||
|
||||
Reference in New Issue
Block a user