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
Kazuhiko Shiozaki
gitlab-ce
Commits
2b94f5fb
Commit
2b94f5fb
authored
Sep 20, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow RelativeLinkFilter to go up multiple directories
parent
619f04c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
lib/gitlab/markdown/relative_link_filter.rb
lib/gitlab/markdown/relative_link_filter.rb
+1
-2
spec/lib/gitlab/markdown/relative_link_filter_spec.rb
spec/lib/gitlab/markdown/relative_link_filter_spec.rb
+8
-0
No files found.
lib/gitlab/markdown/relative_link_filter.rb
View file @
2b94f5fb
...
...
@@ -91,8 +91,7 @@ module Gitlab
parts
=
request_path
.
split
(
'/'
)
parts
.
pop
if
path_type
(
request_path
)
!=
'tree'
# Allow for going up one directory
if
parts
.
length
>
1
&&
path
.
start_with?
(
'../'
)
while
parts
.
length
>
1
&&
path
.
start_with?
(
'../'
)
parts
.
pop
path
.
sub!
(
'../'
,
''
)
end
...
...
spec/lib/gitlab/markdown/relative_link_filter_spec.rb
View file @
2b94f5fb
...
...
@@ -85,6 +85,14 @@ module Gitlab::Markdown
to
eq
"/
#{
project_path
}
/blob/
#{
ref
}
/doc/api/README.md"
end
it
'rebuilds relative URL for a file in the repo up multiple directories'
do
relative_link
=
link
(
'../../../api/README.md'
)
doc
=
filter
(
relative_link
,
requested_path:
'doc/foo/bar/baz/README.md'
)
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
"/
#{
project_path
}
/blob/
#{
ref
}
/doc/api/README.md"
end
it
'rebuilds relative URL for a file in the repo with an anchor'
do
doc
=
filter
(
link
(
'README.md#section'
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
...
...
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