Hacker News new | ask | show | jobs
by hamaluik 1597 days ago
Does your site need to redirect me to the French version (https://faut-il-https-sur-mon-site.fr/) just because I'm in Canada?

No, no it does not.

3 comments

It's based on your browser's Accept-Language header, nothing to do with location.

(It's only a naive implementation of parsing the Accept-Language header. Sorry, was all I could do at the time.)

Chrome sets it if you tell it you want to use its spellchecker with some languages.

I'm not sure what the standard says, but i suspect you'd surprise users considerably less if you used the first language listed in that header rather than the last (assuming equal or missing q values).

It's been years since I looked at the code/config but I literally think it's a "strings.Contains()" call... so not even parsing at all.

A proper implementation would make for a good Caddy module.

Yeah you're parser is too broken to be useful. For example with this header, listing English and French in that order, even explicitly indicating a bad quality value for French:

    Accept-Language: en-US;q=1.0, en;q=1.0, fr-FR;q=0.5, fr;q=0.5
your website redirects to faut-il-https-sur-mon-site.fr. Turn this off.
Doesn't redirect for me, also in Canada /shrug
Me neither. I am even in Quebec, but on an English device.
Oddly, I got the Dutch version. I do have Dutch language installed on my phone, but it's definitely not the default. Odd.