How to use linkify-urls - 2 common examples

To help you get started, we’ve selected a few linkify-urls examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / refined-github / source / libs / dom-formatters.ts View on Github external
export function linkifyURLs(element: Element): void {
	if (element.textContent!.length < 15) { // Must be long enough for a URL
		return;
	}

	const linkified = linkifyURLsCore(element.textContent!, {
		type: 'dom' as const,
		attributes: {
			rel: 'noreferrer noopener',
			class: linkifiedURLClass // Necessary to avoid also shortening the links
		}
	});

	if (linkified.children.length === 0) { // Children are <a>
		return;
	}

	zipTextNodes(element, linkified);
}
</a>
github getsentry / freight / static / components / TaskDetails.jsx View on Github external
/***********************************************************************
        This creates an eventlistener for each time element.
        Fine for current average log size(8-15-17), but memory usuage will spike
        for really big logs.
        ***********************************************************************/
        this.highLightDiv(time);

        const timer = new Date(logDataResults.timeStamp[j]);
        const timeMil = timer.getTime();
        //Multiple by 60000 to convert offset to milliseconds
        const offset = timer.getTimezoneOffset() * 60000;
        const timezone = timeMil - offset;
        const newDate = new Date(timezone);

        div.innerHTML = ansi_up.ansi_to_html(
          linkifyUrls(lineItem[j][k], {
            attributes: {
              target: '_blank',
              rel: 'noreferrer noopener',
            },
          })
        );
        time.innerHTML = format(newDate, 'h:mm:ss aa');

        div.appendChild(time);
        frag.appendChild(div);
      }
    }
    this.refs.log.appendChild(frag);

    this.centerHighlightedDiv();

linkify-urls

Linkify URLs in a string

MIT
Latest version published 1 month ago

Package Health Score

81 / 100
Full package analysis

Popular linkify-urls functions