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
ea8e86da
Commit
ea8e86da
authored
Apr 24, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `%r{}` regexes to avoid having to escape `/`
parent
39efd0c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
app/validators/dynamic_path_validator.rb
app/validators/dynamic_path_validator.rb
+1
-1
spec/validators/dynamic_path_validator_spec.rb
spec/validators/dynamic_path_validator_spec.rb
+5
-5
No files found.
app/validators/dynamic_path_validator.rb
View file @
ea8e86da
...
...
@@ -104,7 +104,7 @@ class DynamicPathValidator < ActiveModel::EachValidator
end
def
self
.
contains_path_part?
(
path
,
part
)
path
=~
/(.*\/|\A)
#{
Regexp
.
quote
(
part
)
}
(\/.*|\z)/
path
=~
%r{(/|
\A
)
#{
Regexp
.
quote
(
part
)
}
(/|
\z
)}
end
def
self
.
follow_format?
(
value
)
...
...
spec/validators/dynamic_path_validator_spec.rb
View file @
ea8e86da
...
...
@@ -63,13 +63,13 @@ describe DynamicPathValidator do
# - Followed by one or more path-parts not starting with `:` or `*`
# - Followed by a path-part that includes a wildcard parameter `*`
# At the time of writing these routes match: http://rubular.com/r/Rv2pDE5Dvw
STARTING_WITH_NAMESPACE
=
/^\/\*namespace_id\/:(project_)?id/
NON_PARAM_PARTS
=
/[^:*][a-z\-_\/]*/
ANY_OTHER_PATH_PART
=
/[a-z\-_\/:]*/
WILDCARD_SEGMENT
=
/\*/
STARTING_WITH_NAMESPACE
=
%r{^/
\*
namespace_id/:(project_)?id}
NON_PARAM_PARTS
=
%r{[^:*][a-z
\-
_/]*}
ANY_OTHER_PATH_PART
=
%r{[a-z
\-
_/:]*}
WILDCARD_SEGMENT
=
%r{
\*
}
let
(
:namespaced_wildcard_routes
)
do
routes_without_format
.
select
do
|
p
|
p
=~
%r{
#{
STARTING_WITH_NAMESPACE
}
\/
#{
NON_PARAM_PARTS
}
\
/
#{
ANY_OTHER_PATH_PART
}#{
WILDCARD_SEGMENT
}
}
p
=~
%r{
#{
STARTING_WITH_NAMESPACE
}
/
#{
NON_PARAM_PARTS
}
/
#{
ANY_OTHER_PATH_PART
}#{
WILDCARD_SEGMENT
}
}
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