Angular2-jwt: 1.0.0 and 1.0.0-beta10, Fix for ReferenceError: URL is not defined

Created on 19 Feb 2018  路  6Comments  路  Source: auth0/angular2-jwt

1.0.0-beta10 produces ReferenceError: URL is not defined.

Here is the proposed fix which seems to work for me in:
jwt.interceptor.ts

const URL = require('url');

  // inside isWhitelistedDomain method
  isWhitelistedDomain(request: HttpRequest<any>): boolean {
    // const requestUrl = new URL(request.url);
    const requestUrl = URL.parse(request.url, false, true);
    ...

Most helpful comment

PR submitted.

All 6 comments

I have an issue as well. This is a regression.
I cannot use relative URL to my backend anymore.
It throws an error:

TypeError: Failed to construct 'URL': Invalid URL

It was working fine on 1.0.0-beta.9.
I will stick to the older version for now...

@merlosy - please see #477 for relative URL discussion and possible security implications / workarounds.

@chenkie I was hoping this fix would make it into 1.0.0. Can you please prioritize this (it's a one-liner).
Thanks.

@merlosy this isn't regression, it's simply a bug that was avoided by handling the error that throw. By removing the try catch in beta10 made this error showed up. In beta9 iswhitelisted is always true when your use "undefined" url (partial). Your solution seems to work @noomaans, you should create a pr.

PR submitted.

Thanks @chenkie

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaumard picture jaumard  路  5Comments

mahendra2125 picture mahendra2125  路  4Comments

guillaume-skwid picture guillaume-skwid  路  5Comments

Eddman picture Eddman  路  3Comments

wannabegeek picture wannabegeek  路  3Comments