detect-external-link
Version:
Node.js plugin that analyzes the given link and determines if the URL is internal or external.
23 lines (18 loc) • 417 B
text/typescript
;
import detectExternalLink from './index';
const multipleHosts = {
'hosts': [
'http://example.com',
'http://test.example.com',
]
};
const singleHost = {
'hosts': ['http://example.com']
};
const testLink = 'https://example.com';
if (singleHost) {
console.log(detectExternalLink(testLink, singleHost));
}
if (multipleHosts) {
console.log(detectExternalLink(testLink, multipleHosts));
}