react-code-dataset / next.js /packages /next /src /next-devtools /dev-overlay /utils /parse-url-from-text.ts
Download next.js/packages/next/src/next-devtools/dev-overlay/utils/parse-url-from-text.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 333 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/next-devtools/dev-overlay/utils/parse-url-from-text.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/next-devtools/dev-overlay/utils/parse-url-from-text.ts
-
curl -L -o parse-url-from-text.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/next-devtools/dev-overlay/utils/parse-url-from-text.ts
333 Bytes
| export function parseUrlFromText( | |
| text: string, | |
| matcherFunc?: (text: string) => boolean | |
| ): string[] { | |
| const linkRegex = /https?:\/\/[^\s/$.?#].[^\s)'"]*/gi | |
| const links = Array.from(text.matchAll(linkRegex), (match) => match[0]) | |
| if (matcherFunc) { | |
| return links.filter((link) => matcherFunc(link)) | |
| } | |
| return links | |
| } | |