From f956b86e14219b17de5ef4ea8ae77f3827cfa55b Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Wed, 1 Oct 2025 12:09:29 +0100 Subject: [PATCH] Removed redundant Tool urlPath from tool registryEntry --- frontend/src/data/toolsTaxonomy.ts | 6 ++---- .../src/data/useTranslatedToolRegistry.tsx | 2 -- frontend/src/hooks/useToolNavigation.ts | 2 +- frontend/src/utils/urlRouting.ts | 20 ++----------------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/frontend/src/data/toolsTaxonomy.ts b/frontend/src/data/toolsTaxonomy.ts index 7b62a0cb5..dc9538128 100644 --- a/frontend/src/data/toolsTaxonomy.ts +++ b/frontend/src/data/toolsTaxonomy.ts @@ -37,8 +37,6 @@ export type ToolRegistryEntry = { endpoints?: string[]; link?: string; type?: string; - // URL path for routing (e.g., '/split-pdfs', '/compress-pdf') - urlPath?: string; // Workbench type for navigation workbench?: WorkbenchType; // Operation configuration for automation @@ -130,8 +128,8 @@ export const getToolWorkbench = (tool: ToolRegistryEntry): WorkbenchType => { /** * Get URL path for a tool */ -export const getToolUrlPath = (toolId: string, tool: ToolRegistryEntry): string => { - return tool.urlPath || `/${toolId.replace(/([A-Z])/g, '-$1').toLowerCase()}`; +export const getToolUrlPath = (toolId: string): string => { + return `/${toolId.replace(/([A-Z])/g, '-$1').toLowerCase()}`; }; /** diff --git a/frontend/src/data/useTranslatedToolRegistry.tsx b/frontend/src/data/useTranslatedToolRegistry.tsx index 920c654ee..39d74ede5 100644 --- a/frontend/src/data/useTranslatedToolRegistry.tsx +++ b/frontend/src/data/useTranslatedToolRegistry.tsx @@ -483,7 +483,6 @@ export function useFlatToolRegistry(): ToolRegistry { categoryId: ToolCategoryId.STANDARD_TOOLS, subcategoryId: SubcategoryId.PAGE_FORMATTING, maxFiles: -1, - urlPath: '/pdf-to-single-page', endpoints: ["pdf-to-single-page"], operationConfig: singleLargePageOperationConfig, synonyms: getSynonyms(t, "pdfToSinglePage") @@ -830,7 +829,6 @@ export function useFlatToolRegistry(): ToolRegistry { categoryId: ToolCategoryId.RECOMMENDED_TOOLS, subcategoryId: SubcategoryId.GENERAL, maxFiles: -1, - urlPath: '/ocr-pdf', operationConfig: ocrOperationConfig, settingsComponent: OCRSettings, synonyms: getSynonyms(t, "ocr") diff --git a/frontend/src/hooks/useToolNavigation.ts b/frontend/src/hooks/useToolNavigation.ts index 5c6fcf47c..1fdc8f2c7 100644 --- a/frontend/src/hooks/useToolNavigation.ts +++ b/frontend/src/hooks/useToolNavigation.ts @@ -22,7 +22,7 @@ export function useToolNavigation(): { const getToolNavigation = useCallback((toolId: string, tool: ToolRegistryEntry): ToolNavigationProps => { // Generate SSR-safe relative path - const path = getToolUrlPath(toolId, tool); + const path = getToolUrlPath(toolId); const href = path; // Relative path, no window.location needed // Click handler that maintains SPA behavior diff --git a/frontend/src/utils/urlRouting.ts b/frontend/src/utils/urlRouting.ts index d14ca923a..14bc3752f 100644 --- a/frontend/src/utils/urlRouting.ts +++ b/frontend/src/utils/urlRouting.ts @@ -33,7 +33,7 @@ export function parseToolRoute(registry: ToolRegistry): ToolRoute { // Fallback: Try to find tool by primary URL path in registry for (const [toolId, tool] of Object.entries(registry)) { - const toolUrlPath = getToolUrlPath(toolId, tool); + const toolUrlPath = getToolUrlPath(toolId); if (path === toolUrlPath && isValidToolId(toolId)) { return { workbench: getToolWorkbench(tool), @@ -88,7 +88,7 @@ export function updateToolRoute(toolId: ToolId, registry: ToolRegistry, replace: return; } - const toolPath = getToolUrlPath(toolId, tool); + const toolPath = getToolUrlPath(toolId); const newPath = withBasePath(toolPath); const searchParams = new URLSearchParams(window.location.search); @@ -116,19 +116,3 @@ export function getToolDisplayName(toolId: ToolId, registry: ToolRegistry): stri return tool ? tool.name : toolId; } -/** - * Generate shareable URL for current tool state using registry - */ -export function generateShareableUrl(toolId: ToolId | null, registry: ToolRegistry): string { - const baseUrl = window.location.origin; - - if (!toolId || !registry[toolId]) { - return `${baseUrl}${BASE_PATH || ''}`; - } - - const tool = registry[toolId]; - - const toolPath = getToolUrlPath(toolId, tool); - const fullPath = withBasePath(toolPath); - return `${baseUrl}${fullPath}`; -}