From aa59cad589dc8db84dcb7eb1174b0d94806ab01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E9=B9=B0?= <17kungfuboy@gmail.com> Date: Fri, 9 Sep 2022 18:05:24 +0800 Subject: [PATCH] feat: render real link --- .../pages/api/websocket/websocket.component.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/workbench/browser/src/app/pages/api/websocket/websocket.component.ts b/src/workbench/browser/src/app/pages/api/websocket/websocket.component.ts index 90f4d4ba..8eab02ea 100644 --- a/src/workbench/browser/src/app/pages/api/websocket/websocket.component.ts +++ b/src/workbench/browser/src/app/pages/api/websocket/websocket.component.ts @@ -138,7 +138,7 @@ export class WebsocketComponent implements OnInit, OnDestroy { // * save to test history this.model.response.responseBody.unshift({ type: 'end', - msg: 'Disconnect from ' + this.model.request.uri, + msg: 'Disconnect from ' + this.getLink(), isExpand: false, }); const { requestTabIndex, msg, ...data } = this.model; @@ -195,6 +195,7 @@ export class WebsocketComponent implements OnInit, OnDestroy { this.wsStatus = 'connected'; this.model.requestTabIndex = 2; const { reqHeader, resHeader } = content; + this.model.response.responseBody.unshift({ type: 'start', msg: { @@ -207,14 +208,14 @@ export class WebsocketComponent implements OnInit, OnDestroy { value, })), }, - title: 'Connected to ' + this.model.request.uri, + title: 'Connected to ' + this.getLink(), isExpand: false, }); } else { this.model.response.responseBody.unshift({ type: 'end', msg: content, - title: 'Connected to ' + this.model.request.uri + ` is failed`, + title: 'Connected to ' + this.getLink() + ` is failed`, isExpand: false, }); this.wsStatus = 'disconnect'; @@ -270,6 +271,14 @@ export class WebsocketComponent implements OnInit, OnDestroy { }); }); }; + private getLink() { + const { uri, protocol } = this.model.request; + const link = /^(wss:\/{2})|(ws:\/{2})\S+$/m.test(uri.trim()) + ? uri.trim() + : protocol + '://' + uri.trim().replace('//', ''); + console.log('link', link); + return link; + } private resetModel() { return { requestTabIndex: 2,