Skip to content

Commit 3ae7597

Browse files
committed
fix: handle sampleUrl parsing more robustly
1 parent 7162d81 commit 3ae7597

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/app/views/common/share.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { authenticationWrapper } from '../../../modules/authentication';
21
import { IQuery } from '../../../types/query-runner';
2+
import { authenticationWrapper } from '../../../modules/authentication';
33
import { encodeHashCharacters } from '../../utils/query-url-sanitization';
44
import { parseSampleUrl } from '../../utils/sample-url-generation';
55

@@ -17,8 +17,15 @@ export const createShareLink = (sampleQuery: IQuery, authenticated?: boolean): s
1717
return '';
1818
}
1919

20-
const url = new URL(sampleUrl);
21-
const graphUrl = url.origin;
20+
let graphUrl = 'https://graph.microsoft.com';
21+
22+
try {
23+
const url = new URL(sampleUrl);
24+
graphUrl = url.origin;
25+
} catch {
26+
// do nothing and use default graph url
27+
}
28+
2229
const appUrl = 'https://developer.microsoft.com/graph/graph-explorer';
2330

2431
const graphUrlRequest = encodeURIComponent(requestUrl + search);

0 commit comments

Comments
 (0)