Handle if ENV.MOMENT_LOCALE is en-US (or something else invalid)

Somehow, one of our developers got into a state where ENV.MOMENT_LOCALE
for them is "en-US", even though that should never happen. From that 
same browser when hitting our prod app servers it says 
MOMENT_LOCALE is “en”

So since we can’t figure out how one would ever get into that situation,
I don’t know how to reproduce it so can’t make a spec that does. But
this is here, just in case, so it doesn’t give us a 500 error if that 
does ever happen to anyone else.

Change-Id: I5d6ec11d46ec0ceebe69ac267facbd2f03f1b017
Reviewed-on: https://gerrit.instructure.com/194040
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2019-05-16 16:06:46 -06:00
parent cedc0090bc
commit f6201b3e44
1 changed files with 2 additions and 1 deletions

View File

@ -183,7 +183,8 @@ module ApplicationHelper
# if there is a moment locale besides english set, put a script tag for it
# so it is loaded and ready before we run any of our app code
if js_env[:MOMENT_LOCALE] && js_env[:MOMENT_LOCALE] != 'en'
@script_chunks += Canvas::Cdn::RevManifest.all_webpack_chunks_for("moment/locale/#{js_env[:MOMENT_LOCALE]}")
moment_chunks = Canvas::Cdn::RevManifest.all_webpack_chunks_for("moment/locale/#{js_env[:MOMENT_LOCALE]}")
@script_chunks += moment_chunks if moment_chunks
end
@script_chunks += Canvas::Cdn::RevManifest.all_webpack_chunks_for("main")
@script_chunks.uniq!