MCPcopy Index your code
hub / github.com/angular/angular / getLocaleData

Function getLocaleData

packages/core/src/i18n/locale_data_api.ts:105–123  ·  view source on GitHub ↗
(normalizedLocale: string)

Source from the content-addressed store, hash-verified

103 * or from the global `ng.common.locale`.
104 */
105export function getLocaleData(normalizedLocale: string): any {
106 if (!(normalizedLocale in LOCALE_DATA)) {
107 const globalLocaleData =
108 global.ng &&
109 global.ng.common &&
110 global.ng.common.locales &&
111 global.ng.common.locales[normalizedLocale];
112 // Only cache global locale data when an entry is actually found, to avoid
113 // caching missing lookups. In SSR this cache is process-wide across requests,
114 // so caching `undefined` would retain attacker-controlled locale identifiers
115 // indefinitely. It would also make the `in` check above short-circuit on
116 // subsequent lookups and skip the global fallback.
117 if (globalLocaleData !== undefined) {
118 LOCALE_DATA[normalizedLocale] = globalLocaleData;
119 }
120 return globalLocaleData;
121 }
122 return LOCALE_DATA[normalizedLocale];
123}
124
125/**
126 * Helper function to remove all the locale data from `LOCALE_DATA`.

Callers 1

findLocaleDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected