moderator-toolbox-nxg-for-reddit / modules/domaintagger/matching

modules/domaintagger/matching

Functions

findTagForDomain()

findTagForDomain(domain, domainTags): DomainTag | null

Defined in: extension/data/modules/domaintagger/matching.ts:31

Returns the first DomainTag matching domain, using this priority order:

  1. Exact match (domain === tag.name)

  2. Glob match (tag name contains *, tested with matchesGlob)

  3. Suffix match (domain ends with the tag name) Returns null if no tag matches.

Parameters

domain

string

The full domain string to test (e.g. "i.imgur.com").

domainTags

DomainTag[]

The configured tag list to search.

Returns

DomainTag | null


matchesGlob()

matchesGlob(domain, pattern): boolean

Defined in: extension/data/modules/domaintagger/matching.ts:15

Tests whether domain matches a glob pattern. The pattern’s regex metacharacters are escaped and each * is expanded to .*, then anchored to match the whole string.

Parameters

domain

string

The full domain string to test (e.g. "i.imgur.com").

pattern

string

A glob pattern containing at least one *.

Returns

boolean