Skip to content

Commit 1c3967c

Browse files
authored
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
1 parent 1be6c5b commit 1c3967c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/@vuepress/theme-default/components/PageEdit.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ export default {
8080
methods: {
8181
createEditLink (repo, docsRepo, docsDir, docsBranch, path) {
8282
const bitbucket = /bitbucket.org/
83-
if (bitbucket.test(repo)) {
84-
const base = outboundRE.test(docsRepo) ? docsRepo : repo
83+
if (bitbucket.test(docsRepo)) {
84+
const base = docsRepo
8585
return (
8686
base.replace(endingSlashRE, '')
8787
+ `/src`
@@ -92,12 +92,24 @@ export default {
9292
)
9393
}
9494
95+
const gitlab = /gitlab.com/
96+
if (gitlab.test(docsRepo)) {
97+
const base = docsRepo
98+
return (
99+
base.replace(endingSlashRE, '')
100+
+ `/-/edit`
101+
+ `/${docsBranch}/`
102+
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
103+
+ path
104+
)
105+
}
106+
95107
const base = outboundRE.test(docsRepo)
96108
? docsRepo
97109
: `https://github.com/${docsRepo}`
98110
return (
99111
base.replace(endingSlashRE, '')
100-
+ `/edit`
112+
+ '/edit'
101113
+ `/${docsBranch}/`
102114
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
103115
+ path

0 commit comments

Comments
 (0)