Skip to content

Commit

Permalink
Merge pull request #179 from nulib/5304-bad-uri
Browse files Browse the repository at this point in the history
Don't match getty on bad uri with colon at start of string
  • Loading branch information
kdid authored Dec 12, 2024
2 parents 33a4a20 + 82686fa commit d94e200
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/authoritex/getty/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ defmodule Authoritex.Getty.Base do

@impl Authoritex
def can_resolve?(unquote(http_uri) <> _id), do: true
def can_resolve?(unquote(prefix) <> _id), do: true
def can_resolve?(unquote(prefix) <> _ = id) do
unquote(prefix) != ":"
end
def can_resolve?(_), do: false

@impl Authoritex
Expand Down
5 changes: 5 additions & 0 deletions test/authoritex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ defmodule AuthoritexTest do
assert Authoritex.fetch("info:fake/no-authority/12345") ==
{:error, :unknown_authority}
end

test "bad uri" do
assert Authoritex.fetch(":http://id.loc.gov/authorities/names/no2009131449") ==
{:error, :unknown_authority}
end
end

describe "search/2" do
Expand Down

0 comments on commit d94e200

Please sign in to comment.