|
84 | 84 | import{unreachable}from'devlop' |
85 | 85 | import{toJsxRuntime}from'hast-util-to-jsx-runtime' |
86 | 86 | import{urlAttributes}from'html-url-attributes' |
87 | | -import{sanitizeUri}from'micromark-util-sanitize-uri' |
88 | 87 | // @ts-expect-error: untyped. |
89 | 88 | import{Fragment,jsx,jsxs}from'react/jsx-runtime' |
90 | 89 | importremarkParsefrom'remark-parse' |
@@ -297,5 +296,26 @@ export function Markdown(options) { |
297 | 296 | * Safe URL. |
298 | 297 | */ |
299 | 298 | exportfunctiondefaultUrlTransform(value){ |
300 | | -returnsanitizeUri(value,safeProtocol) |
| 299 | +// Same as: |
| 300 | +// <https://github.com/micromark/micromark/blob/929275e/packages/micromark-util-sanitize-uri/dev/index.js#L34> |
| 301 | +// But without the `encode` part. |
| 302 | +constcolon=value.indexOf(':') |
| 303 | +constquestionMark=value.indexOf('?') |
| 304 | +constnumberSign=value.indexOf('#') |
| 305 | +constslash=value.indexOf('/') |
| 306 | + |
| 307 | +if( |
| 308 | +// If there is no protocol, it’s relative. |
| 309 | +colon<0|| |
| 310 | +// If the first colon is after a `?`, `#`, or `/`, it’s not a protocol. |
| 311 | +(slash>-1&&colon>slash)|| |
| 312 | +(questionMark>-1&&colon>questionMark)|| |
| 313 | +(numberSign>-1&&colon>numberSign)|| |
| 314 | +// It is a protocol, it should be allowed. |
| 315 | +safeProtocol.test(value.slice(0,colon)) |
| 316 | +){ |
| 317 | +returnvalue |
| 318 | +} |
| 319 | + |
| 320 | +return'' |
301 | 321 | } |
0 commit comments