From 1c3967c565eeb4ff00ac11bf0dc3c72b0abe0a98 Mon Sep 17 00:00:00 2001 From: fulop <43729152+fulopkovacs@users.noreply.github.com> Date: Mon, 3 Aug 2020 16:53:34 +0200 Subject: [PATCH] fix($theme-default): fix editLink for repos hosted on gitlab.com (#2523) * fix($theme-default): fix editLink for repos hosted on gitlab.com * refactor($theme-default): refactor the gitlab edit links * refactor($theme-default): refactor bitbucket edit links --- .../theme-default/components/PageEdit.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/theme-default/components/PageEdit.vue b/packages/@vuepress/theme-default/components/PageEdit.vue index 9f5319b990..cf9b2d25c0 100644 --- a/packages/@vuepress/theme-default/components/PageEdit.vue +++ b/packages/@vuepress/theme-default/components/PageEdit.vue @@ -80,8 +80,8 @@ export default { methods: { createEditLink (repo, docsRepo, docsDir, docsBranch, path) { const bitbucket = /bitbucket.org/ - if (bitbucket.test(repo)) { - const base = outboundRE.test(docsRepo) ? docsRepo : repo + if (bitbucket.test(docsRepo)) { + const base = docsRepo return ( base.replace(endingSlashRE, '') + `/src` @@ -92,12 +92,24 @@ export default { ) } + const gitlab = /gitlab.com/ + if (gitlab.test(docsRepo)) { + const base = docsRepo + return ( + base.replace(endingSlashRE, '') + + `/-/edit` + + `/${docsBranch}/` + + (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') + + path + ) + } + const base = outboundRE.test(docsRepo) ? docsRepo : `https://github.com/${docsRepo}` return ( base.replace(endingSlashRE, '') - + `/edit` + + '/edit' + `/${docsBranch}/` + (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') + path