From d332ae1132fca0d078170bbb399845c7edb1fa8d Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Tue, 9 Apr 2019 18:23:21 -0700 Subject: [PATCH] Fix to ensure that we rewrite spark ui links correctly (#4962) --- .../workbench/parts/notebook/models/cell.ts | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/sql/workbench/parts/notebook/models/cell.ts b/src/sql/workbench/parts/notebook/models/cell.ts index 6099494eaa..bc7702cad1 100644 --- a/src/sql/workbench/parts/notebook/models/cell.ts +++ b/src/sql/workbench/parts/notebook/models/cell.ts @@ -390,16 +390,8 @@ export class CellModel implements ICellModel { let endpoint = this.getKnoxEndpoint(model.activeConnection); let host = endpoint && endpoint.ipAddress ? endpoint.ipAddress : model.activeConnection.serverName; let html = result.data['text/html']; - html = html.replace(/(https?:\/\/mssql-master.*\/proxy)(.*)/g, function (a, b, c) { - let ret = ''; - if (b !== '') { - ret = 'https://' + host + ':30443/gateway/default/yarn/proxy'; - } - if (c !== '') { - ret = ret + c; - } - return ret; - }); + html =this.rewriteUrlUsingRegex(/(https?:\/\/mssql-master.*\/proxy)(.*)/g, html, host); + html =this.rewriteUrlUsingRegex(/(https?:\/\/master.*master-svc.*\/proxy)(.*)/g, html, host); (output).data['text/html'] = html; } } @@ -409,6 +401,19 @@ export class CellModel implements ICellModel { return output; } + private rewriteUrlUsingRegex(regex: RegExp, html: string, host: string): string { + return html.replace(regex, function (a, b, c) { + let ret = ''; + if (b !== '') { + ret = 'https://' + host + ':30443/gateway/default/yarn/proxy'; + } + if (c !== '') { + ret = ret + c; + } + return ret; + }); + } + private getDisplayId(msg: nb.IIOPubMessage): string | undefined { let transient = (msg.content.transient || {}); return transient['display_id'] as string;