Skip to content

Commit

Permalink
Merge pull request #13671 from imtayadeway/api/fix-cid-namespacing
Browse files Browse the repository at this point in the history
Fix cid constant namespacing in the API
  • Loading branch information
abellotti authored Jan 27, 2017
2 parents 097f22c + 522366b commit 22bf342
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions app/controllers/api/base_controller/parser.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Api
class BaseController
module Parser
include CompressedIds

def parse_api_request
@req = RequestAdapter.new(request, params)
end
Expand Down Expand Up @@ -104,7 +102,7 @@ def parse_id(resource, collection)
end

def href_id(href, collection)
if href.present? && href.match(%r{^.*/#{collection}/(#{CID_OR_ID_MATCHER})$})
if href.present? && href.match(%r{^.*/#{collection}/(#{BaseController::CID_OR_ID_MATCHER})$})
from_cid(Regexp.last_match(1))
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/subcollections/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def parse_policy(data, collection, klass)
return klass.find_by(:guid => guid) if guid.present?

href = data["href"]
href =~ %r{^.*/#{collection}/#{CID_OR_ID_MATCHER}$} ? klass.find(from_cid(href.split('/').last)) : {}
href =~ %r{^.*/#{collection}/#{BaseController::CID_OR_ID_MATCHER}$} ? klass.find(from_cid(href.split('/').last)) : {}
end

def policy_subcollection_action(ctype, policy)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/subcollections/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parse_tag(data)

def parse_tag_from_href(data)
href = data["href"]
tag = if href && href.match(%r{^.*/tags/#{CID_OR_ID_MATCHER}$})
tag = if href && href.match(%r{^.*/tags/#{BaseController::CID_OR_ID_MATCHER}$})
klass = collection_class(:tags)
klass.find(from_cid(href.split('/').last))
end
Expand Down

0 comments on commit 22bf342

Please sign in to comment.