






















@@ -3,7 +3,7 @@ import { resolveUserPath } from "../utils.js";
33import type { PluginCandidate } from "./discovery.js";
44import { loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-records.js";
55import type { PluginManifestRecord } from "./manifest-registry.js";
6-import { isPathInside, safeStatSync } from "./path-safety.js";
6+import { isPathInside, safeRealpathSync, safeStatSync } from "./path-safety.js";
77import type { PluginRecord, PluginRegistry } from "./registry.js";
88import type { PluginLogger } from "./types.js";
99@@ -44,15 +44,16 @@ function addPathToMatcher(
4444if (!resolved) {
4545return;
4646}
47-if (matcher.exact.has(resolved) || matcher.dirs.includes(resolved)) {
47+const canonical = safeRealpathSync(resolved) ?? resolved;
48+if (matcher.exact.has(canonical) || matcher.dirs.includes(canonical)) {
4849return;
4950}
50-const stat = safeStatSync(resolved);
51+const stat = safeStatSync(canonical);
5152if (stat?.isDirectory()) {
52-matcher.dirs.push(resolved);
53+matcher.dirs.push(canonical);
5354return;
5455}
55-matcher.exact.add(resolved);
56+matcher.exact.add(canonical);
5657}
57585859function matchesPathMatcher(matcher: PathMatcher, sourcePath: string): boolean {
@@ -101,16 +102,17 @@ function isTrackedByProvenance(params: {
101102env: NodeJS.ProcessEnv;
102103}): boolean {
103104const sourcePath = resolveUserPath(params.source, params.env);
105+const canonicalSourcePath = safeRealpathSync(sourcePath) ?? sourcePath;
104106const installRule = params.index.installRules.get(params.pluginId);
105107if (installRule) {
106108if (installRule.trackedWithoutPaths) {
107109return true;
108110}
109-if (matchesPathMatcher(installRule.matcher, sourcePath)) {
111+if (matchesPathMatcher(installRule.matcher, canonicalSourcePath)) {
110112return true;
111113}
112114}
113-return matchesPathMatcher(params.index.loadPathMatcher, sourcePath);
115+return matchesPathMatcher(params.index.loadPathMatcher, canonicalSourcePath);
114116}
115117116118function matchesExplicitInstallRule(params: {
@@ -120,11 +122,12 @@ function matchesExplicitInstallRule(params: {
120122env: NodeJS.ProcessEnv;
121123}): boolean {
122124const sourcePath = resolveUserPath(params.source, params.env);
125+const canonicalSourcePath = safeRealpathSync(sourcePath) ?? sourcePath;
123126const installRule = params.index.installRules.get(params.pluginId);
124127if (!installRule || installRule.trackedWithoutPaths) {
125128return false;
126129}
127-return matchesPathMatcher(installRule.matcher, sourcePath);
130+return matchesPathMatcher(installRule.matcher, canonicalSourcePath);
128131}
129132130133function resolveCandidateDuplicateRank(params: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。