Skip to content

Repository files navigation

detect-external-link

NPM versionDownloadsAppVeyor Build StatusDownloads

JavaScript plugin that analyzes the given link and determines if the URL is internal or external. To ensure accuracy, please include a list of specified hosts that should be marked as internal. This way, the plugin can effectively differentiate between internal and external links based on the provided hosts list.

Install

Via npm

npm install detect-external-link

Via Yarn

yarn add detect-external-link

For vanilla HTML in modern browsers, import detect-external-link from jsDelivr:

<scripttype="module">importdetectExternalLinkfrom'https://cdn.jsdelivr.net/npm/detect-external-link@2/+esm';console.log(detectExternalLink('http://test.example2.com/test/abc/',{'hosts': ['http://example.com','http://test.example.com']}));</script>

Usage

importdetectExternalLinkfrom'/js/index.js';constlink='http://test.example2.com/test/abc/';constlinkOptions={'hosts': ['http://example.com','http://test.example.com']};console.log(detectExternalLink(link,linkOptions));

Parameters

AttributesTypeRequiredDefaultDescription
hostsArrayYes[]Site hostname(s) to detect external links.

About

Node.js plugin that analyzes the given link and determines if the URL is internal or external.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages