Skip to content

Commit f694628

Browse files
TkDodoandrewshie-sentry
authored andcommitted
fix: check for URIError instead of URI malformed error message (#97663)
Checking for `err.message === 'URI malformed'` is brittle because: 1. Messages can differ per browser, [according to MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_URI): ``` URIError: URI malformed (V8-based) URIError: malformed URI sequence (Firefox) URIError: String contained an illegal UTF-16 sequence. (Safari) ``` 2. The current code only compiles because `err` is implicitly `any`; When switching to `unknown`, it will error because `message` might not exist. --- Switching to an `err instanceof URIError` check should fix both problems. /edit: apparently, this has been fixed in ReactRouter v5, so we shouldn’t even hit this path: - remix-run/history#656
1 parent 78c67c8 commit f694628

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

static/app/bootstrap/renderMain.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function renderMain() {
77
try {
88
renderDom(Main, `#${ROOT_ELEMENT}`, {});
99
} catch (err) {
10-
if (err.message === 'URI malformed') {
10+
if (err instanceof URIError) {
1111
// eslint-disable-next-line no-console
1212
console.error(
1313
new Error(

0 commit comments

Comments
 (0)