assetgraph / hreftypes

Figure out what type a href is. Useful to help resolve URI's between assets on a site

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hreftypes

NPM version Build Status Coverage Status Dependency Status

Hreftypes helps you determine if a href is of type absolute, protocolRelative, rootRelative, relative or inline. This can be useful while resolving URI's across different types of assets in a website dependency graph.

Installation

npm install --save- hreftypes

Usage

const assert = require('assert');
const { hrefTypes, getHrefType } = require('hreftype');

assert(getHrefType('http://foo.com') === hrefTypes.ABSOLUTE);
assert(getHrefType('https://foo.com') === hrefTypes.ABSOLUTE);
assert(getHrefType('//foo.com') === hrefTypes.PROTOCOL_RELATIVE);
assert(getHrefType('/foo.com') === hrefTypes.ROOT_RELATIVE);
assert(getHrefType('foo.com') === hrefTypes.RELATIVE);
assert(getHrefType('data:text/html,<h1>Hi</h1>') === hrefTypes.INLINE);

License

BSD 3-Clause License

About

Figure out what type a href is. Useful to help resolve URI's between assets on a site

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 100.0%