The language tag to test
The language range to match against
true if the tag matches the range pattern
import { matchTag, asTag, asTagRange } from "@metreeca/core";
matchTag(asTag("de-DE"), asTagRange("de-*-DE")); // true
matchTag(asTag("de-Latn-DE"), asTagRange("de-*-DE")); // true
matchTag(asTag("de"), asTagRange("de-*-DE")); // false - missing 'DE'
matchTag(asTag("de-x-DE"), asTagRange("de-*-DE")); // false - singleton 'x' blocks
Checks if a language tag matches a language range.
Implements Extended Filtering per RFC 4647 § 3.3.2. Matching is case-insensitive and compares subtags sequentially:
*in range matches any subtag sequence