Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix($theme-default): fix editLink for repos hosted on gitlab.com #2523

Merged
merged 3 commits into from
Aug 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@vuepress/theme-default/components/PageEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second expression (repo) of the ternary operator would never get executed in the refactored implementation, since the value of docsRepo must be a full url (it must contain the bitbucket.org string), which means that it will always match the outboundRE regex pattern (which is /^[a-z]+:/i (from line 4 of packages/@vuepress/theme-default/util/index.js)), so the base variable would always get its initial value from docsRepo.

I tried to understand the original intention behind this line, but it just seemed to be wrong to me: if docsRepo had been defined by the user as group(or user)/project (like vuejs/vuepress), then the base variable used the value of repo, which is the url of the main site's repo, and not the repo of the docs. Not to mention, that a group(or user)/project-style docsRepo value suggests a GitHub repo and not a BitBucket one.

if (bitbucket.test(docsRepo)) {
const base = docsRepo
return (
base.replace(endingSlashRE, '')
+ `/src`
Expand Down