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
74b74e59
Commit
74b74e59
authored
May 17, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for import URL URI problem when URL contains a space
parent
28eea9bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
lib/gitlab/import_url.rb
lib/gitlab/import_url.rb
+5
-1
spec/lib/gitlab/import_url_spec.rb
spec/lib/gitlab/import_url_spec.rb
+17
-4
No files found.
lib/gitlab/import_url.rb
View file @
74b74e59
module
Gitlab
class
ImportUrl
def
initialize
(
url
,
credentials:
nil
)
@url
=
URI
.
parse
(
URI
.
encode
(
url
))
@url
=
URI
.
parse
(
encode
(
url
))
@credentials
=
credentials
end
...
...
@@ -37,5 +37,9 @@ module Gitlab
def
valid_credentials?
credentials
&&
credentials
.
is_a?
(
Hash
)
&&
credentials
.
any?
end
def
encode
(
url
)
URI
.
decode
(
url
).
size
<
url
.
size
?
url
:
URI
.
encode
(
url
)
end
end
end
spec/lib/gitlab/import_url_spec.rb
View file @
74b74e59
...
...
@@ -3,19 +3,32 @@ require 'spec_helper'
describe
Gitlab
::
ImportUrl
do
let
(
:credentials
)
{
{
user:
'blah'
,
password:
'password'
}
}
let
(
:url
)
{
"https://github.com/me/project.git"
}
let
(
:import_url
)
do
Gitlab
::
ImportUrl
.
new
(
"https://github.com/me/project.git"
,
credentials:
credentials
)
described_class
.
new
(
url
,
credentials:
credentials
)
end
describe
:full_url
do
describe
'full_url'
do
it
{
expect
(
import_url
.
full_url
).
to
eq
(
"https://blah:password@github.com/me/project.git"
)
}
end
describe
:sanitized_url
do
describe
'sanitized_url'
do
it
{
expect
(
import_url
.
sanitized_url
).
to
eq
(
"https://github.com/me/project.git"
)
}
end
describe
:credentials
do
describe
'credentials'
do
it
{
expect
(
import_url
.
credentials
).
to
eq
(
credentials
)
}
end
context
'URL encoding'
do
describe
'not encoded URL'
do
let
(
:url
)
{
"https://github.com/me/my project.git"
}
it
{
expect
(
import_url
.
sanitized_url
).
to
eq
(
"https://github.com/me/my%20project.git"
)
}
end
describe
'already encoded URL'
do
let
(
:url
)
{
"https://github.com/me/my%20project.git"
}
it
{
expect
(
import_url
.
sanitized_url
).
to
eq
(
"https://github.com/me/my%20project.git"
)
}
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