From fc5367346b7f92154b9af3bc3fb43784066d2bb3 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Thu, 28 Jul 2022 16:24:53 -0400 Subject: [PATCH] Use CGI.escape instead of URI.escape This is okay because we strip spaces, which CGI.escape apparently doesn't escape to spec. closes #5272 Co-authored-by: Trey Pendragon --- app/decorators/ephemera_term_decorator.rb | 2 +- spec/decorators/ephemera_term_decorator_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/decorators/ephemera_term_decorator.rb b/app/decorators/ephemera_term_decorator.rb index bfda625ca4..36edd733d4 100644 --- a/app/decorators/ephemera_term_decorator.rb +++ b/app/decorators/ephemera_term_decorator.rb @@ -21,7 +21,7 @@ def external_uri_exists? def internal_url return Array.wrap(model.uri).first if vocabulary.blank? vocabulary_uri = vocabulary.uri.to_s.end_with?("/") ? vocabulary.uri.to_s : vocabulary.uri.to_s + "/" - URI.join(vocabulary_uri, URI.escape(camelized_label)) + URI.join(vocabulary_uri, CGI.escape(camelized_label)) end def uri diff --git a/spec/decorators/ephemera_term_decorator_spec.rb b/spec/decorators/ephemera_term_decorator_spec.rb index 0a6bbbb4ad..9a2a0483f2 100644 --- a/spec/decorators/ephemera_term_decorator_spec.rb +++ b/spec/decorators/ephemera_term_decorator_spec.rb @@ -37,7 +37,7 @@ context "when the term contains UTF-8 characters" do let(:resource) { FactoryBot.create_for_repository(:ephemera_term, label: "San José, Costa Rica", member_of_vocabulary_id: vocabulary.id) } it "still generates a figgy uri" do - expect(resource.decorate.internal_url.to_s).to eq "https://figgy.princeton.edu/ns/testVocabulary/sanJos%C3%A9,CostaRica" + expect(resource.decorate.internal_url.to_s).to eq "https://figgy.princeton.edu/ns/testVocabulary/sanJos%C3%A9%2CCostaRica" end end