Skip to content

Commit

Permalink
Don't match getty on bad uri with colon at start of string
Browse files Browse the repository at this point in the history
  • Loading branch information
kdid committed Dec 12, 2024
1 parent 33a4a20 commit 82686fa
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 82686fa

Please sign in to comment.