Closed okkindel closed 1 year ago
I hesitated about it... and decided to throw and to use it in a try-catch. Maybe it was a wrong choice. That is right that at least the function docs should mention it, and it does not yet. Why do you think that this function should not throw?
So, I decided to throw as the default behavior, but starting from 1.9.2, you can prevent that using a 3rd argument:
const translatedUrl = fileUrlToUrl(fileUrl, locale, { throwOnError: false })
It will return undefined instead of throwing an error.
fileUrlToUrl function should be protected for nonexistent paths.