fix(next/font): case insensitivity in local font extension check #83353
+18
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Validating local fonts fails with an "Unexpected file" error if the extension in the provided font file's path is not lowercase (e.g. "MYFONT.WOFF"). This PR converts the path into all lowercase before checking it with the regex. I decided not to use the case insensitive regex flag to avoid breaking later logic that uses the result of the check.
A new unit test was also included to test for case insensitivity.
Somewhat related suggestion: the error message is a bit vague at the moment and it's not clear that the error happens due to an unsupported extension. It took me quite a bit to debug the issue when I faced it and I would've never realized why it happens if I didn't take a look at the source code 😅 Would be neat if the error message specifically pointed this out (and maybe even displayed a list of supported extensions).