Protection against non-parsable Accept-Language header

This commit is contained in:
Claude Brisson
2024-05-09 06:53:38 +02:00
parent c79344c3d1
commit 539ece97f4
2 changed files with 11 additions and 1 deletions

View File

@@ -25,7 +25,13 @@
<span class="info"></span>
<select name="country" placeholder="country">
<option></option>
#set($defaultCountry = $countries.country.first)
#set($countryFromPreferredLanguage = $countries.country)
#if($countryFromPreferredLanguage)
#set($defaultCountry = $countryFromPreferredLanguage.first)
#else
## Accept-Language could not be parsed
#set($defaultCountry = 'en')
#end
#foreach($country in $countries.countries)
<option value="$country.key" #if($tour && $country.key.toLowerCase() == $tour.country.toLowerCase() || !$tour && $country.key.toLowerCase() == $defaultCountry.toLowerCase()) selected #end>$country.value</option>
#end