Skip to content

Fix `SyntaxError: Unexpected token` in SAST jobs

Paul Gascou-Vaillancourt requested to merge sast-catch-unexpected-token into master

What does this MR do?

This fixes the syntax error reported in SAST jobs, ie: https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/225163563

SyntaxError: in/app/assets/javascripts/lib/utils/url_utility.js: Unexpected token, expected ( (155:10)
  153 |     const parsedUrl = new URL(url, getBaseURL());
  154 |     return ['http:', 'https:'].includes(parsedUrl.protocol);
> 155 |   } catch {
      |           ^
  156 |     return false;
  157 |   }
  158 | }

The exception identifier should be specified in the catch block, even if it isn't used: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#The_exception_identifier

Merge request reports