INNER CODE UNIT · TypeScript
resourceHost
ahmet/awesome-web3 · lib/catalog.ts:54
export function resourceHost(url: string) {
try {
return new URL(url).hostname.replace(/^www\./, '')
} catch {
return url
}
}
export function matchesQuery(resource: Resource, query: string) {
if (!query) return true
const q = query.trim().toLowerCase()
if (!q) return true
return [resource.title, resource.description, resource.category, resource.subcategory ?? '', resource.url, resourceHost(resource.url)].join(' ').toLowerCase().includes(q)
}
function textOf(node: MdNode | undefined): string {
if (!node) return ''
if (node.type === 'text' || node.type === 'inlineCode') {