@metreeca/core - v0.9.17
    Preparing search index...

    Function matchTag

    • 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:

      • Wildcard * in range matches any subtag sequence
      • Singleton subtags (single character) in tag block further matching
      • Range subtags must appear in order, but tag may have additional subtags between matches

      Parameters

      • tag: string

        The language tag to test

      • range: string

        The language range to match against

      Returns boolean

      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