mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 01:19:24 +00:00
Url Map
This commit is contained in:
parent
1e866bc31e
commit
66ea3fbcba
33
frontend/src/utils/urlMapping.ts
Normal file
33
frontend/src/utils/urlMapping.ts
Normal 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'
|
||||
};
|
@ -9,6 +9,7 @@ import {
|
||||
} from '../types/navigation';
|
||||
import { ToolRegistry, getToolWorkbench, getToolUrlPath, isValidToolId } from '../data/toolsTaxonomy';
|
||||
import { firePixel } from './scarfTracking';
|
||||
import { URL_TO_TOOL_MAP } from './urlMapping';
|
||||
|
||||
/**
|
||||
* 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 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)) {
|
||||
const toolUrlPath = getToolUrlPath(toolId, tool);
|
||||
if (path === toolUrlPath) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user