I'm trying to match the request URL sent to my ASP.NET application case-insensitively because bots or users might mistakenly request a non-canonical form and I need to redirect them.
Which one of the comparison modes is semantically the best choice?
StringComparison.OrdinalIgnoreCase
StringComparison.InvariantCultureIgnoreCase
StringComparison.CurrentCultureIgnoreCase
Ordinal
might be to restrictive because it does code-point matching. Might not account for all linguistic variations. CurrentCulture
does not seem right for URLs because URLs are supposed to not be culture-specific. InvariantCulture
also does not fully make sense because it represents an English-like culture that does not exist on the planet. I'd rather not use it for user-facing strings, not even for the URL in the browser.
Which mode is the right one?