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
70611316
Commit
70611316
authored
Nov 07, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor namespace regex
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
76ff9fff
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
23 deletions
+28
-23
config/routes/group.rb
config/routes/group.rb
+1
-1
config/routes/user.rb
config/routes/user.rb
+23
-22
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+4
-0
No files found.
config/routes/group.rb
View file @
70611316
...
...
@@ -3,7 +3,7 @@ require 'constraints/group_url_constrainer'
constraints
(
GroupUrlConstrainer
.
new
)
do
scope
(
path:
':id'
,
as: :group
,
constraints:
{
id:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
},
constraints:
{
id:
Gitlab
::
Regex
.
namespace_route_regex
},
controller: :groups
)
do
get
'/'
,
action: :show
patch
'/'
,
action: :update
...
...
config/routes/user.rb
View file @
70611316
...
...
@@ -14,15 +14,15 @@ end
constraints
(
UserUrlConstrainer
.
new
)
do
scope
(
path:
':username'
,
as: :user
,
constraints:
{
username:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
},
constraints:
{
username:
Gitlab
::
Regex
.
namespace_route_regex
},
controller: :users
)
do
get
'/'
,
action: :show
end
end
scope
(
path:
'users/:username'
,
scope
(
constraints:
{
username:
Gitlab
::
Regex
.
namespace_route_regex
})
do
scope
(
path:
'users/:username'
,
as: :user
,
constraints:
{
username:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
},
controller: :users
)
do
get
:calendar
get
:calendar_activities
...
...
@@ -32,13 +32,14 @@ scope(path: 'users/:username',
get
:snippets
get
:exists
get
'/'
,
to:
redirect
(
'/%{username}'
)
end
end
# Compatibility with old routing
# TODO (dzaporozhets): remove in 10.0
get
'/u/:username'
,
to:
redirect
(
'/%{username}'
),
constraints:
{
username:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
}
# TODO (dzaporozhets): remove in 9.0
get
'/u/:username/groups'
,
to:
redirect
(
'/users/%{username}/groups'
),
constraints:
{
username:
/[a-zA-Z.0-9_\-]+/
}
get
'/u/:username/projects'
,
to:
redirect
(
'/users/%{username}/projects'
),
constraints:
{
username:
/[a-zA-Z.0-9_\-]+/
}
get
'/u/:username/snippets'
,
to:
redirect
(
'/users/%{username}/snippets'
),
constraints:
{
username:
/[a-zA-Z.0-9_\-]+/
}
get
'/u/:username/contributed'
,
to:
redirect
(
'/users/%{username}/contributed'
),
constraints:
{
username:
/[a-zA-Z.0-9_\-]+/
}
# Compatibility with old routing
# TODO (dzaporozhets): remove in 10.0
get
'/u/:username'
,
to:
redirect
(
'/%{username}'
)
# TODO (dzaporozhets): remove in 9.0
get
'/u/:username/groups'
,
to:
redirect
(
'/users/%{username}/groups'
)
get
'/u/:username/projects'
,
to:
redirect
(
'/users/%{username}/projects'
)
get
'/u/:username/snippets'
,
to:
redirect
(
'/users/%{username}/snippets'
)
get
'/u/:username/contributed'
,
to:
redirect
(
'/users/%{username}/contributed'
)
end
lib/gitlab/regex.rb
View file @
70611316
...
...
@@ -8,6 +8,10 @@ module Gitlab
@namespace_regex
||=
/\A
#{
NAMESPACE_REGEX_STR
}
\z/
.
freeze
end
def
namespace_route_regex
@namespace_route_regex
||=
/
#{
NAMESPACE_REGEX_STR
}
/
.
freeze
end
def
namespace_regex_message
"can contain only letters, digits, '_', '-' and '.'. "
\
"Cannot start with '-' or end in '.', '.git' or '.atom'."
\
...
...
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