Skip to content

Commit

Permalink
Merge pull request #138 from dunn/idregexp
Browse files Browse the repository at this point in the history
FileSystemFileResolver: teach #validate_identifier to handle ints
  • Loading branch information
jcoyne committed Apr 6, 2021
2 parents bdfa710 + e0a3025 commit 90e216a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/resolvers/riiif/file_system_file_resolver.rb
Expand Up @@ -14,7 +14,7 @@ def pattern(id)

# @return [Boolean] true if the id matches the regex
def validate_identifier(id:, regex: identifier_regex)
return true if id =~ regex
return true if id.to_s =~ regex
Rails.logger.warn "Invalid characters in id `#{id}`"
false
end
Expand Down
7 changes: 7 additions & 0 deletions spec/models/riiif/file_system_file_resolver_spec.rb
Expand Up @@ -78,5 +78,12 @@
expect(subject).to be_nil
end
end

context 'as an integer' do
let(:id) { 1 }
it 'converts it to a string before parsing' do
expect { subject }.not_to raise_error
end
end
end
end

0 comments on commit 90e216a

Please sign in to comment.