Commit 1c088017 authored by Nick Thomas's avatar Nick Thomas

Allow nested namespaces in git URLs

parent c8589c13
...@@ -30,14 +30,12 @@ type routeEntry struct { ...@@ -30,14 +30,12 @@ type routeEntry struct {
matchers []matcherFunc matchers []matcherFunc
} }
const projectPattern = `^/[^/]+/[^/]+/` const (
const gitProjectPattern = `^/[^/]+/[^/]+\.git/` apiPattern = `^/api/`
ciAPIPattern = `^/ci/api/`
const apiPattern = `^/api/` gitProjectPattern = `^/([^/]+/){1,}[^/]+\.git/`
projectPattern = `^/([^/]+/){1,}[^/]+/`
// A project ID in an API request is either a number or two strings 'namespace/project' )
const projectsAPIPattern = `^/api/v3/projects/((\d+)|([^/]+/[^/]+))/`
const ciAPIPattern = `^/ci/api/`
func compileRegexp(regexpStr string) *regexp.Regexp { func compileRegexp(regexpStr string) *regexp.Regexp {
if len(regexpStr) == 0 { if len(regexpStr) == 0 {
......
...@@ -178,6 +178,8 @@ func TestRegularProjectsAPI(t *testing.T) { ...@@ -178,6 +178,8 @@ func TestRegularProjectsAPI(t *testing.T) {
"/api/v3/projects/foo%2Fbar/repository/not/special", "/api/v3/projects/foo%2Fbar/repository/not/special",
"/api/v3/projects/123/not/special", "/api/v3/projects/123/not/special",
"/api/v3/projects/foo%2Fbar/not/special", "/api/v3/projects/foo%2Fbar/not/special",
"/api/v3/projects/foo%2Fbar%2Fbaz/repository/not/special",
"/api/v3/projects/foo%2Fbar%2Fbaz%2Fqux/repository/not/special",
} { } {
resp, err := http.Get(ws.URL + resource) resp, err := http.Get(ws.URL + resource)
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment