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
iv
gitlab-ce
Commits
70f9893e
Commit
70f9893e
authored
Apr 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explain namespace clearn regex.
parent
456e3a70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
app/models/namespace.rb
app/models/namespace.rb
+5
-0
db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb
...ate/20150421120000_remove_periods_at_ends_of_usernames.rb
+5
-0
No files found.
app/models/namespace.rb
View file @
70f9893e
...
@@ -60,10 +60,15 @@ class Namespace < ActiveRecord::Base
...
@@ -60,10 +60,15 @@ class Namespace < ActiveRecord::Base
def
clean_path
(
path
)
def
clean_path
(
path
)
path
=
path
.
dup
path
=
path
.
dup
# Get the email username by removing everything after an `@` sign.
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/@.*\z/
,
""
)
# Usernames can't end in .git, so remove it.
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
# Remove dashes at the start of the username.
path
.
gsub!
(
/\A-+/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
# Remove periods at the end of the username.
path
.
gsub!
(
/\.+\z/
,
""
)
path
.
gsub!
(
/\.+\z/
,
""
)
# Remove everything that's not in the list of allowed characters.
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
# Users with the great usernames of "." or ".." would end up with a blank username.
# Users with the great usernames of "." or ".." would end up with a blank username.
...
...
db/migrate/20150421120000_remove_periods_at_ends_of_usernames.rb
View file @
70f9893e
...
@@ -9,10 +9,15 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
...
@@ -9,10 +9,15 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
def
clean_path
(
path
)
def
clean_path
(
path
)
path
=
path
.
dup
path
=
path
.
dup
# Get the email username by removing everything after an `@` sign.
path
.
gsub!
(
/@.*\z/
,
""
)
path
.
gsub!
(
/@.*\z/
,
""
)
# Usernames can't end in .git, so remove it.
path
.
gsub!
(
/\.git\z/
,
""
)
path
.
gsub!
(
/\.git\z/
,
""
)
# Remove dashes at the start of the username.
path
.
gsub!
(
/\A-+/
,
""
)
path
.
gsub!
(
/\A-+/
,
""
)
# Remove periods at the end of the username.
path
.
gsub!
(
/\.+\z/
,
""
)
path
.
gsub!
(
/\.+\z/
,
""
)
# Remove everything that's not in the list of allowed characters.
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
path
.
gsub!
(
/[^a-zA-Z0-9_\-\.]/
,
""
)
# Users with the great usernames of "." or ".." would end up with a blank username.
# Users with the great usernames of "." or ".." would end up with a blank username.
...
...
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