Skip to content

Commit 3abb497

Browse files
committed
Allow Orcid IDs/URLs to have been issued from the sandbox
1 parent 9c3e7f6 commit 3abb497

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/bolognese/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ def orcid_as_url(orcid)
574574
end
575575

576576
def validate_orcid(orcid)
577-
orcid = Array(/\A(?:(http|https):\/\/(www\.)?orcid\.org\/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\z/.match(orcid)).last
577+
orcid = Array(/\A(?:(?:http|https):\/\/(?:(?:www|sandbox)?\.)?orcid\.org\/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\z/.match(orcid)).last
578578
orcid.gsub(/[[:space:]]/, "-") if orcid.present?
579579
end
580580

spec/utils_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@
6464
expect(response).to eq("0000-0002-1394-3097")
6565
end
6666

67+
it "validate_orcid sandbox" do
68+
orcid = "http://sandbox.orcid.org/0000-0002-2590-225X"
69+
response = subject.validate_orcid(orcid)
70+
expect(response).to eq("0000-0002-2590-225X")
71+
end
72+
73+
it "validate_orcid sandbox https" do
74+
orcid = "https://sandbox.orcid.org/0000-0002-2590-225X"
75+
response = subject.validate_orcid(orcid)
76+
expect(response).to eq("0000-0002-2590-225X")
77+
end
78+
6779
it "validate_orcid wrong id" do
6880
orcid = "0000-0002-1394-309"
6981
response = subject.validate_orcid(orcid)

0 commit comments

Comments
 (0)