Skip to content

Commit

Permalink
Merge pull request #8 from projecthydra-labs/fix_to_uri
Browse files Browse the repository at this point in the history
translate_uri_to_id should handle deeper paths. Fixes #7
  • Loading branch information
Trey Terrell committed May 13, 2015
2 parents 14dce8d + c1251e9 commit d958643
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_fedora/noid/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def treeifier
end

def translate_uri_to_id
lambda { |uri| uri.to_s.split('/')[-1] }
lambda { |uri| URI(uri).path.split('/', 9).last }
end

def translate_id_to_uri
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@
end
end
end

describe '#translate_uri_to_id' do
let(:translator) { described_class.new.translate_uri_to_id }
let(:uri) { "http://localhost:8983/fedora/rest/test/hh/63/vz/22/hh63vz22q/members" }
subject { translator.call(uri) }

it { is_expected.to eq 'hh63vz22q/members' }
end
end

0 comments on commit d958643

Please sign in to comment.