All files / scripts/sitemap-xml hreflang.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                            530956x 496080x    
/**
 * @module Infrastructure/SitemapXml/Hreflang
 * @category Intelligence Operations / Supporting Infrastructure
 * @name Hreflang code mapping
 *
 * @description
 * Pure helper that maps a file-suffix language code (the suffix used in
 * filenames like `…_no.html`) to a proper BCP-47 hreflang code (e.g.
 * Norwegian uses the suffix `no` but hreflang must be `nb`).
 *
 * Round-6 split: extracted from `scripts/generate-sitemap.ts`.
 *
 * @author Hack23 AB (Infrastructure Team)
 * @license Apache-2.0
 */
 
/**
 * Map a file-suffix language code to its BCP-47 hreflang code.
 * Norwegian files use the suffix `no` but hreflang should be `nb` (Bokmål).
 * All other codes pass through unchanged.
 */
export function hreflangCode(lang: string): string {
  if (lang === 'no') return 'nb';
  return lang;
}