File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
lib/travis/api/app/endpoint Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -52,21 +52,25 @@ class Repos < Endpoint
52
52
end
53
53
end
54
54
55
- # Gets the repository with the given id.
56
- #
55
+ # Given a single string, consider two cases:
56
+ # 1. string consisting entirely of digits
57
57
# ### Response
58
58
#
59
59
# json(:repository)
60
- get '/:id' do
61
- prefer_follower do
62
- respond_with service ( :find_repo , params )
63
- end
64
- end
65
-
66
- # Retrieves repositories for a given owner.
67
- get '/:owner_name' do
60
+ #
61
+ # 2. All other cases
62
+ # ### Response
63
+ #
64
+ # array of repositories owned by that owner
65
+ get '/((?<id>\d+)|(?<owner_name>[^\/]+))' , mustermann_opts : { type : :regexp } do
68
66
prefer_follower do
69
- respond_with service ( :find_repos , params ) . run
67
+ if params [ :id ]
68
+ params . delete :owner_name
69
+ respond_with service ( :find_repo , params )
70
+ elsif params [ :owner_name ]
71
+ params . delete :id
72
+ respond_with service ( :find_repos , params ) . run
73
+ end
70
74
end
71
75
end
72
76
You can’t perform that action at this time.
0 commit comments