@@ -38,23 +38,19 @@ The parameter syncing patterns in `src/utils.ts` have been updated to focus on:
3838- Navigation links now automatically include ferried parameters
3939- Maintains the existing Button styling and behavior
4040
41- ### 4. Automatic Parameter Ferrying Component
41+ ### 4. Safe Parameter Ferrying Link Component
4242
43- ** ParamFerry Component** (` src/components/paramFerry.tsx ` ):
44- - A client-side component that automatically processes all links on the page
45- - Uses MutationObserver to handle dynamically added links
46- - Skips external links, anchors, mailto, and tel links
47- - Marks processed links to avoid duplicate processing
48-
49- ** Added to Layout** (` app/layout.tsx ` ):
50- - The ParamFerry component is included in the root layout
51- - Works automatically across all pages without additional setup
43+ ** ParamFerryLink Component** (` src/components/paramFerryLink.tsx ` ):
44+ - A safe Link component that handles parameter ferrying at the component level
45+ - No DOM manipulation - parameters are ferried during rendering
46+ - Only processes internal links (starting with ` / ` or ` # ` )
47+ - Can be used as a drop-in replacement for Next.js Link component
5248
5349## How It Works
5450
55- 1 . ** Page Load ** : When a page loads with URL parameters matching the patterns, the ParamFerry component identifies them
56- 2 . ** Link Processing ** : All internal links on the page are processed to include the relevant parameters
57- 3 . ** Dynamic Updates ** : New links added to the page (via JavaScript) are automatically processed
51+ 1 . ** Component Rendering ** : When link components render, they check for matching URL parameters in the current page
52+ 2 . ** Parameter Extraction ** : Parameters matching the specified patterns are extracted from the current URL
53+ 3 . ** URL Construction ** : Parameters are safely appended to internal link URLs during component rendering
58544 . ** Navigation** : When users click internal links, they carry forward the tracked parameters
5955
6056## Examples
@@ -99,14 +95,22 @@ import {NavLink} from 'sentry-docs/components/navlink';
9995<NavLink href = " /docs/guides/" >Guides</NavLink >
10096```
10197
98+ ### Using ParamFerryLink
99+ ``` tsx
100+ import {ParamFerryLink } from ' sentry-docs/components/paramFerryLink' ;
101+
102+ // Safe component-level parameter ferrying
103+ <ParamFerryLink href = " /docs/getting-started/" >Get Started</ParamFerryLink >
104+ ```
105+
102106## Security Features
103107
104108The implementation includes comprehensive security measures:
105- - ** URL Scheme Validation ** : Blocks dangerous URL schemes ( ` javascript: ` , ` data: ` , ` vbscript: ` , ` file: ` , ` about: ` )
106- - ** Parameter Sanitization ** : Sanitizes parameter keys and values to prevent injection attacks
107- - ** Length Limits ** : Parameter values are limited to 500 characters
108- - ** Control Character Filtering ** : Removes control characters from parameters
109- - ** Multiple Validation Layers ** : URLs are validated at multiple stages of processing
109+ - ** Same-Origin Policy ** : Only processes URLs from the same origin to prevent cross-site attacks
110+ - ** Internal Links Only ** : Component-level ferrying only applies to internal links (starting with ` / ` or ` # ` )
111+ - ** No DOM Manipulation ** : Avoids security risks associated with modifying existing DOM elements
112+ - ** Parameter Length Limits ** : Parameter values are limited to 200 characters
113+ - ** Type Validation** : Ensures all parameters are strings before processing
110114
111115## Browser Compatibility
112116
0 commit comments