Skip to content

Commit

Permalink
only removes quotes and field:
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Dec 14, 2022
1 parent c3dc7c1 commit 94a897c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/utilities/string_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def self.prefixes

def self.strip_symbols(str)
# str.gsub(/[\p{P}\p{Sm}\p{Sc}\p{So}^`]/, "")
str.gsub(/["'(){}\[\]]/, "")
str.gsub(/["']/, "")
end

# TODO: add bits to remove field prefix (e.g., 'author:') as defined in 00-catalog.yml
# this is where the author browse specific cleaning goes
def self.cleanup_author_browse_string(str)
prefixes.each do |x|
if str.match?(/^#{x}:["(]/)
if str.match?(/^#{x}:/)
str.sub!(/^#{x}:/, "")
break
end
Expand Down
4 changes: 2 additions & 2 deletions spec/utilities/string_cleaner_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
describe StringCleaner do
context ".strip_symbols" do
it "removes certain punctuation" do
expect(described_class.strip_symbols('"\'(){}[]')).to eq("")
expect(described_class.strip_symbols('"\'')).to eq("")
end
end
context ".cleanup_author_browse_string" do
it "removes 'author:' prefix" do
expect(described_class.cleanup_author_browse_string('author:"Author Name"')).to eq("Author Name")
end
it "removes 'isn(' prefix" do
expect(described_class.cleanup_author_browse_string('isn:("123-456")')).to eq("123-456")
expect(described_class.cleanup_author_browse_string("isn:(123-456)")).to eq("(123-456)")
end
end
end

0 comments on commit 94a897c

Please sign in to comment.