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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bc937494
Commit
bc937494
authored
Jan 24, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
11c29cca
a949043d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
0 deletions
+61
-0
changelogs/unreleased/sh-fix-upload-snippets-with-relative-url-root.yml
...eleased/sh-fix-upload-snippets-with-relative-url-root.yml
+5
-0
lib/banzai/filter/relative_link_filter.rb
lib/banzai/filter/relative_link_filter.rb
+2
-0
spec/lib/banzai/filter/relative_link_filter_spec.rb
spec/lib/banzai/filter/relative_link_filter_spec.rb
+54
-0
No files found.
changelogs/unreleased/sh-fix-upload-snippets-with-relative-url-root.yml
0 → 100644
View file @
bc937494
---
title
:
Fix 404s for snippet uploads when relative URL root used
merge_request
:
24588
author
:
type
:
fixed
lib/banzai/filter/relative_link_filter.rb
View file @
bc937494
...
...
@@ -58,6 +58,8 @@ module Banzai
path_parts
.
unshift
(
relative_url_root
,
'groups'
,
group
.
full_path
,
'-'
)
elsif
project
path_parts
.
unshift
(
relative_url_root
,
project
.
full_path
)
else
path_parts
.
unshift
(
relative_url_root
)
end
begin
...
...
spec/lib/banzai/filter/relative_link_filter_spec.rb
View file @
bc937494
...
...
@@ -353,5 +353,59 @@ describe Banzai::Filter::RelativeLinkFilter do
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
'http://example.com'
end
end
context
'to a personal snippet'
do
let
(
:group
)
{
nil
}
let
(
:project
)
{
nil
}
let
(
:relative_path
)
{
'/uploads/-/system/personal_snippet/6/674e4f07fbf0a7736c3439212896e51a/example.tar.gz'
}
context
'with an absolute URL'
do
let
(
:absolute_path
)
{
Gitlab
.
config
.
gitlab
.
url
+
relative_path
}
let
(
:only_path
)
{
false
}
it
'rewrites the link correctly'
do
doc
=
filter
(
link
(
relative_path
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
(
absolute_path
)
end
end
context
'with a relative URL root'
do
let
(
:gitlab_root
)
{
'/gitlab'
}
let
(
:absolute_path
)
{
Gitlab
.
config
.
gitlab
.
url
+
gitlab_root
+
relative_path
}
before
do
stub_config_setting
(
relative_url_root:
gitlab_root
)
end
context
'with an absolute URL'
do
let
(
:only_path
)
{
false
}
it
'rewrites the link correctly'
do
doc
=
filter
(
link
(
relative_path
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
(
absolute_path
)
end
end
it
'rewrites the link correctly'
do
doc
=
filter
(
link
(
relative_path
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
(
gitlab_root
+
relative_path
)
end
end
it
'rewrites the link correctly'
do
doc
=
filter
(
link
(
relative_path
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
(
relative_path
)
end
it
'does not modify absolute URL'
do
doc
=
filter
(
link
(
'http://example.com'
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
'http://example.com'
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