This commit is contained in:
Connor Yoh 2025-08-28 12:37:49 +01:00
parent 1e866bc31e
commit 66ea3fbcba
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,33 @@
import { ToolId } from '../types/navigation';
// Map URL paths to tool keys (multiple URLs can map to same tool)
export const URL_TO_TOOL_MAP: Record<string, ToolId> = {
'/split-pdfs': 'split',
'/split': 'split',
'/merge-pdfs': 'merge',
'/compress-pdf': 'compress',
'/convert': 'convert',
'/convert-pdf': 'convert',
'/file-to-pdf': 'convert',
'/eml-to-pdf': 'convert',
'/html-to-pdf': 'convert',
'/markdown-to-pdf': 'convert',
'/pdf-to-csv': 'convert',
'/pdf-to-img': 'convert',
'/pdf-to-markdown': 'convert',
'/pdf-to-pdfa': 'convert',
'/pdf-to-word': 'convert',
'/pdf-to-xml': 'convert',
'/add-password': 'addPassword',
'/change-permissions': 'changePermissions',
'/sanitize-pdf': 'sanitize',
'/ocr': 'ocr',
'/ocr-pdf': 'ocr',
'/add-watermark': 'addWatermark',
'/remove-password': 'removePassword',
'/single-large-page': 'single-large-page',
'/repair': 'repair',
'/unlock-pdf-forms': 'unlockPdfForms',
'/remove-certificate-sign': 'removeCertificateSign',
'/remove-cert-sign': 'removeCertificateSign'
};

View File

@ -9,6 +9,7 @@ import {
} from '../types/navigation'; } from '../types/navigation';
import { ToolRegistry, getToolWorkbench, getToolUrlPath, isValidToolId } from '../data/toolsTaxonomy'; import { ToolRegistry, getToolWorkbench, getToolUrlPath, isValidToolId } from '../data/toolsTaxonomy';
import { firePixel } from './scarfTracking'; import { firePixel } from './scarfTracking';
import { URL_TO_TOOL_MAP } from './urlMapping';
/** /**
* Parse the current URL to extract tool routing information * Parse the current URL to extract tool routing information
@ -17,7 +18,17 @@ export function parseToolRoute(registry: ToolRegistry): ToolRoute {
const path = window.location.pathname; const path = window.location.pathname;
const searchParams = new URLSearchParams(window.location.search); const searchParams = new URLSearchParams(window.location.search);
// Try to find tool by URL path // First, check URL mapping for multiple URL aliases
const mappedToolId = URL_TO_TOOL_MAP[path];
if (mappedToolId && registry[mappedToolId]) {
const tool = registry[mappedToolId];
return {
workbench: getToolWorkbench(tool),
toolId: mappedToolId
};
}
// Fallback: Try to find tool by primary URL path in registry
for (const [toolId, tool] of Object.entries(registry)) { for (const [toolId, tool] of Object.entries(registry)) {
const toolUrlPath = getToolUrlPath(toolId, tool); const toolUrlPath = getToolUrlPath(toolId, tool);
if (path === toolUrlPath) { if (path === toolUrlPath) {