19 lines
453 B
TypeScript
19 lines
453 B
TypeScript
|
|
'use client'
|
||
|
|
|
||
|
|
import { useEffect, useState } from 'react'
|
||
|
|
|
||
|
|
// Shows the requested URL path; falls back to a placeholder without JS
|
||
|
|
export function RequestedPath() {
|
||
|
|
const [path, setPath] = useState('/gesuchte-seite')
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
const raw = window.location.pathname
|
||
|
|
try {
|
||
|
|
setPath(decodeURI(raw))
|
||
|
|
} catch {
|
||
|
|
setPath(raw) // malformed percent-encoding
|
||
|
|
}
|
||
|
|
}, [])
|
||
|
|
|
||
|
|
return <span className="break-all">{path}</span>
|
||
|
|
}
|