Home Reference Source Repository
public class | source

Whitelist

Whitelist component

Static Method Summary

Static Private Methods
private static

Get the whitelist from localStorage

private static

Get the key to lookup in localStorage for the whitelist.

private static

Set the whitelist in localStorage

private static

testURLs(url: string, pattern: string): boolean

Test URLs.

Constructor Summary

Private Constructor
private

constructor(email: *)

Initialize the instance.

Member Summary

Private Members
private

email: *

Whitelist's Email

Method Summary

Public Methods
public

addURL(title: string, url: string): boolean

Add URL to whitelist.

public

Check if URL is allowed

public

Remove URL from whitelist

Private Methods
private

Get the whitelist in localStorage.

private

set(whitelist: whitelist): boolean

Set the whitelist in localStorage.

Static Private Methods

private static getWhitelistForEmail(email: *): whitelist source

Get the whitelist from localStorage

Params:

NameTypeAttributeDescription
email *

Return:

whitelist

The whitelist

See:

private static getWhitelistKeyForEmail(email: *): string source

Get the key to lookup in localStorage for the whitelist.

Params:

NameTypeAttributeDescription
email *

Return:

string

localStorage key for the whitelist for the given email.

private static setWhitelistForEmail(email: string, whitelist: whitelist): boolean source

Set the whitelist in localStorage

Params:

NameTypeAttributeDescription
email string

The admin's email address.

whitelist whitelist

The whitelist to save.

Return:

boolean

Whether successfully saved.

See:

private static testURLs(url: string, pattern: string): boolean source

Test URLs.

Params:

NameTypeAttributeDescription
url string

URL to test against.

pattern string

URL pattern with glob support to test with.

Return:

boolean

If URL matches pattern

Example:

testURLs('https://google.com','*://google.com/**'); // True
testURLs('https://google.com','*://google.ca/**'); // False

Private Constructors

private constructor(email: *) source

Initialize the instance.

Params:

NameTypeAttributeDescription
email *

Private Members

private email: * source

Whitelist's Email

Public Methods

public addURL(title: string, url: string): boolean source

Add URL to whitelist.

Params:

NameTypeAttributeDescription
title string

Title for whitelist entry

url string

URL for whitelist entry

Return:

boolean

Was successfully added to whitelist

Throw:

Error

URL is already in whitelist.

public isAllowed(url: string): boolean source

Check if URL is allowed

Params:

NameTypeAttributeDescription
url string

The URL to check if whitelist allows.

Return:

boolean

Whether the URL is allowed.

public removeURL(url: string): whitelist source

Remove URL from whitelist

Params:

NameTypeAttributeDescription
url string

The URL to remove from the whitelist

Return:

whitelist

whitelist The updated whitelist

Private Methods

private get(): whitelist source

Get the whitelist in localStorage.

Return:

whitelist

The whitelist.

private set(whitelist: whitelist): boolean source

Set the whitelist in localStorage.

Params:

NameTypeAttributeDescription
whitelist whitelist

The whitelist to save.

Return:

boolean

Whether successfully saved.