提交 4adf3055 编写于 作者: T Tomas Vik

refactor: make sure webview is getting the correct instanceUrl

This fixes a minor bug where if user hasn't configured their
instaenceUrl (presumably they use the default gitlab.com),
the webview is going to put `null` in the links. This fix
makes sure we use the same logic as the rest of the app.
上级 5470de2b
......@@ -5,6 +5,7 @@ const vscode = require('vscode');
const gitLabService = require('./gitlab_service');
const { createGitLabNewService } = require('./service_factory');
const { logError } = require('./log');
const { getInstanceUrl } = require('./utils/get_instance_url');
let context = null;
......@@ -59,6 +60,7 @@ const createPanel = issuable => {
};
const createMessageHandler = (panel, issuable, workspaceFolder) => async message => {
const instanceUrl = await getInstanceUrl(workspaceFolder);
if (message.command === 'renderMarkdown') {
const alteredMarkdown = message.markdown.replace(
/\(\/.*(\/-)?\/merge_requests\//,
......@@ -68,7 +70,7 @@ const createMessageHandler = (panel, issuable, workspaceFolder) => async message
rendered = (rendered || '')
.replace(/ src=".*" alt/gim, ' alt')
.replace(/" data-src/gim, '" src')
.replace(/ href="\//gim, ` href="${vscode.workspace.getConfiguration('gitlab').instanceUrl}/`)
.replace(/ href="\//gim, ` href="${instanceUrl}/`)
.replace(/\/master\/-\/merge_requests\//gim, '/-/merge_requests/');
panel.webview.postMessage({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册