Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
63353815
Commit
63353815
authored
Dec 01, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix URL rewritting in the Help section
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
507abdb7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
13 deletions
+34
-13
app/controllers/help_controller.rb
app/controllers/help_controller.rb
+4
-2
changelogs/unreleased/25199-fix-broken-urls-in-help-page.yml
changelogs/unreleased/25199-fix-broken-urls-in-help-page.yml
+4
-0
spec/controllers/help_controller_spec.rb
spec/controllers/help_controller_spec.rb
+15
-9
spec/features/help_pages_spec.rb
spec/features/help_pages_spec.rb
+11
-2
No files found.
app/controllers/help_controller.rb
View file @
63353815
...
@@ -7,8 +7,10 @@ class HelpController < ApplicationController
...
@@ -7,8 +7,10 @@ class HelpController < ApplicationController
@help_index
=
File
.
read
(
Rails
.
root
.
join
(
'doc'
,
'README.md'
))
@help_index
=
File
.
read
(
Rails
.
root
.
join
(
'doc'
,
'README.md'
))
# Prefix Markdown links with `help/` unless they are external links
# Prefix Markdown links with `help/` unless they are external links
# See http://rubular.com/r/MioSrVLK3S
# See http://rubular.com/r/X3baHTbPO2
@help_index
.
gsub!
(
%r{(
\]\(
)(?!.+://)([^
\)\(
]+
\)
)}
,
'\1/help/\2'
)
@help_index
.
gsub!
(
%r{(?<delim>
\]\(
)(?!.+://)(?!/)(?<link>[^
\)\(
]+
\)
)}
)
do
"
#{
$~
[
:delim
]
}#{
Gitlab
.
config
.
gitlab
.
relative_url_root
}
/help/
#{
$~
[
:link
]
}
"
end
end
end
def
show
def
show
...
...
changelogs/unreleased/25199-fix-broken-urls-in-help-page.yml
0 → 100644
View file @
63353815
---
title
:
Don't change relative URLs to absolute URLs in the Help page
merge_request
:
author
:
spec/controllers/help_controller_spec.rb
View file @
63353815
...
@@ -8,26 +8,32 @@ describe HelpController do
...
@@ -8,26 +8,32 @@ describe HelpController do
end
end
describe
'GET #index'
do
describe
'GET #index'
do
context
'when url prefixed without /help/'
do
context
'with absolute url'
do
it
'has correct url prefix'
do
it
'keeps the URL absolute'
do
stub_readme
(
"[API](api/README.md)"
)
stub_readme
(
"[API](/api/README.md)"
)
get
:index
get
:index
expect
(
assigns
[
:help_index
]).
to
eq
'[API](/help/api/README.md)'
expect
(
assigns
[
:help_index
]).
to
eq
'[API](/api/README.md)'
end
end
end
end
context
'when url prefixed with help'
do
context
'with relative url'
do
it
'will be an absolute path'
do
it
'prefixes it with /help/'
do
stub_readme
(
"[API](helpful_hints/README.md)"
)
stub_readme
(
"[API](api/README.md)"
)
get
:index
get
:index
expect
(
assigns
[
:help_index
]).
to
eq
'[API](/help/helpful_hints/README.md)'
expect
(
assigns
[
:help_index
]).
to
eq
'[API](/help/api/README.md)'
end
end
end
end
context
'when url is an external link'
do
context
'when url is an external link'
do
it
'
will not be changed
'
do
it
'
does not change it
'
do
stub_readme
(
"[external](https://some.external.link)"
)
stub_readme
(
"[external](https://some.external.link)"
)
get
:index
get
:index
expect
(
assigns
[
:help_index
]).
to
eq
'[external](https://some.external.link)'
expect
(
assigns
[
:help_index
]).
to
eq
'[external](https://some.external.link)'
end
end
end
end
...
...
spec/features/help_pages_spec.rb
View file @
63353815
...
@@ -12,9 +12,9 @@ describe 'Help Pages', feature: true do
...
@@ -12,9 +12,9 @@ describe 'Help Pages', feature: true do
end
end
describe
'Get the main help page'
do
describe
'Get the main help page'
do
shared_examples_for
'help page'
do
shared_examples_for
'help page'
do
|
prefix:
''
|
it
'prefixes links correctly'
do
it
'prefixes links correctly'
do
expect
(
page
).
to
have_selector
(
'div.documentation-index > ul a[href="/help/api/README.md"]'
)
expect
(
page
).
to
have_selector
(
%(div.documentation-index > ul a[href="#{prefix}/help/api/README.md"])
)
end
end
end
end
...
@@ -33,5 +33,14 @@ describe 'Help Pages', feature: true do
...
@@ -33,5 +33,14 @@ describe 'Help Pages', feature: true do
it_behaves_like
'help page'
it_behaves_like
'help page'
end
end
context
'with a relative installation'
do
before
do
stub_config_setting
(
relative_url_root:
'/gitlab'
)
visit
help_path
end
it_behaves_like
'help page'
,
prefix:
'/gitlab'
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment