Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!initialized) {
setCode(null)
fetch(rawUrl)
.then(res => res.text().then(text => ({ text, ok: res.ok })))
.then(({ text, ok }) => {
setCode(ok ? text : errorMsg)
})
.catch(err => {
setCode(errorMsg)
console.error(err)
})
setInitialized(true)
}
}, [initialized, rawUrl, errorMsg])
const highlighted = lang === 'none' || !code ? code : highlightCode(lang, code)
return (
<>
<header>
<code>
{rawUrl.split('.com/')[1]}
</code>
</header>
<code>
)
}
</code>