Decode a path segment that may contain RFC 6902-escaped characters back to an hf-id.
(segment: string)
| 41 | |
| 42 | /** Decode a path segment that may contain RFC 6902-escaped characters back to an hf-id. */ |
| 43 | function decodePathSegment(segment: string): string { |
| 44 | // RFC 6902 §3: unescape ~1 → /, then ~0 → ~ (reverse order) |
| 45 | return segment.replace(/~1/g, "/").replace(/~0/g, "~"); |
| 46 | } |
| 47 | |
| 48 | export function stylePath(id: string, prop: string): string { |
| 49 | return `/elements/${escapeIdForPath(id)}/inlineStyles/${prop}`; |