Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { FLAG, getEmptyResult, IOptions, IResult, parseImpl, resetResult } from 'tldts-core';
import suffixLookup from './src/packed-hashes';
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT: IResult = getEmptyResult();
export function parse(url: string, options: Partial = {}): IResult {
return parseImpl(url, FLAG.ALL, suffixLookup, options, getEmptyResult());
}
export function getHostname(
url: string,
options: Partial = {},
): string | null {
resetResult(RESULT);
return parseImpl(url, FLAG.HOSTNAME, suffixLookup, options, RESULT).hostname;
}
export function getPublicSuffix(
url: string,
options: Partial = {},
import { FLAG, getEmptyResult, IOptions, IResult, parseImpl, resetResult } from 'tldts-core';
import suffixLookup from './src/suffix-trie';
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT: IResult = getEmptyResult();
export function parse(url: string, options: Partial = {}): IResult {
return parseImpl(url, FLAG.ALL, suffixLookup, options, getEmptyResult());
}
export function getHostname(
url: string,
options: Partial = {},
): string | null {
resetResult(RESULT);
return parseImpl(url, FLAG.HOSTNAME, suffixLookup, options, RESULT).hostname;
}
export function getPublicSuffix(
url: string,
options: Partial = {},