Fix script slug matching to prevent false positives
- Remove normalized slug/name matching fallback that caused false matches - Use exact slug-to-slug matching as primary method - Only use install basename matching for edge cases - Prevents 'docker-vm' from appearing when only 'docker' is downloaded
This commit is contained in:
@@ -185,13 +185,19 @@ export function DownloadedScriptsTab({ onInstallScript }: DownloadedScriptsTabPr
|
|||||||
// Check if there's a corresponding local script
|
// Check if there's a corresponding local script
|
||||||
const hasLocalVersion = localScriptsData?.scripts?.some(local => {
|
const hasLocalVersion = localScriptsData?.scripts?.some(local => {
|
||||||
if (!local?.name) return false;
|
if (!local?.name) return false;
|
||||||
|
|
||||||
|
// Primary: Exact slug-to-slug matching (most reliable, prevents false positives)
|
||||||
|
if (local.slug && script.slug) {
|
||||||
|
if (local.slug.toLowerCase() === script.slug.toLowerCase()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secondary: Check install basenames (for edge cases where install script names differ from slugs)
|
||||||
|
// Only use normalized matching for install basenames, not for slug/name matching
|
||||||
const normalizedLocal = normalizeId(local.name);
|
const normalizedLocal = normalizeId(local.name);
|
||||||
const matchesNameOrSlug = (
|
|
||||||
normalizedLocal === normalizeId(script.name) ||
|
|
||||||
normalizedLocal === normalizeId(script.slug)
|
|
||||||
);
|
|
||||||
const matchesInstallBasename = (script as any)?.install_basenames?.some((base: string) => normalizeId(base) === normalizedLocal) ?? false;
|
const matchesInstallBasename = (script as any)?.install_basenames?.some((base: string) => normalizeId(base) === normalizedLocal) ?? false;
|
||||||
return matchesNameOrSlug || matchesInstallBasename;
|
return matchesInstallBasename;
|
||||||
}) ?? false;
|
}) ?? false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -216,13 +216,19 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) {
|
|||||||
// Check if there's a corresponding local script
|
// Check if there's a corresponding local script
|
||||||
const hasLocalVersion = localScriptsData?.scripts?.some(local => {
|
const hasLocalVersion = localScriptsData?.scripts?.some(local => {
|
||||||
if (!local?.name) return false;
|
if (!local?.name) return false;
|
||||||
|
|
||||||
|
// Primary: Exact slug-to-slug matching (most reliable, prevents false positives)
|
||||||
|
if (local.slug && script.slug) {
|
||||||
|
if (local.slug.toLowerCase() === script.slug.toLowerCase()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secondary: Check install basenames (for edge cases where install script names differ from slugs)
|
||||||
|
// Only use normalized matching for install basenames, not for slug/name matching
|
||||||
const normalizedLocal = normalizeId(local.name);
|
const normalizedLocal = normalizeId(local.name);
|
||||||
const matchesNameOrSlug = (
|
|
||||||
normalizedLocal === normalizeId(script.name) ||
|
|
||||||
normalizedLocal === normalizeId(script.slug)
|
|
||||||
);
|
|
||||||
const matchesInstallBasename = (script as any)?.install_basenames?.some((base: string) => normalizeId(base) === normalizedLocal) ?? false;
|
const matchesInstallBasename = (script as any)?.install_basenames?.some((base: string) => normalizeId(base) === normalizedLocal) ?? false;
|
||||||
return matchesNameOrSlug || matchesInstallBasename;
|
return matchesInstallBasename;
|
||||||
}) ?? false;
|
}) ?? false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user