LinkData. LinkData

A class for representing the information about a link, in the abstract.

Constructor

new LinkData(url, textopt, descriptionopt)

This constructor throws a ValidationError unless a valid URL is passed.

Parameters:
NameTypeAttributesDescription
urlURL

The link's URL.

textstring<optional>

The link's text, defaults to the URL.

descriptionstring<optional>

A description for the link, defaults to the link text.

Throws:

A validation error is thrown if an invalid URL is passed.

Type
ValidationError

Members

description

description

text

text

uri

Get the URL as a URI.js object.

url

url

Get or set the URL.

Methods

asPlainObject() → {plainObject}

Get the link data as a plain object of the form:

{
    url: 'http://www.bartificer.net/',
    text: 'the link text',
    description: 'the link description',
    uri: {
        hostname: 'www.bartificer.net',
        path: '/',
        hasPath: false
    }
}

Note that the uri could contain more fields - it's initialised with output from the URI.parse() function from the URI module.

Returns:
Type: 
plainObject