mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
434 B
19 lines
434 B
2 years ago
|
export const replaceUrlsWithLink = (text: string): boolean | string => {
|
||
|
if (!text) {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
const rawText = text.toString()
|
||
|
let found = false
|
||
|
const out = rawText.replace(/URI::\((.*?)\)/g, (_, url) => {
|
||
|
found = true
|
||
|
const a = document.createElement('a')
|
||
|
a.textContent = url
|
||
|
a.setAttribute('href', url)
|
||
|
a.setAttribute('target', '_blank')
|
||
|
return a.outerHTML
|
||
|
})
|
||
|
|
||
|
return found && out
|
||
|
}
|