Class: Arxiv::StringScrubber

Inherits:
Object
  • Object
show all
Defined in:
lib/arxiv/string_scrubber.rb

Class Method Summary collapse

Class Method Details

.force_ssl_url(url) ⇒ Object

On approximately Oct 2016, ArXiv seems to have converted their entire site to use SSL. Old HTTP links, still work by redirecting to HTTPS.

Unfortunately, this change is not yet reflected in their API responses (e.g. their API still returns a non-SSL URL). Thus, if you try to use this URL it will redirect to the new SSL URL. This can create problems if the client is not expecting redirects.

Hopefully they will update their API. Until then, this little method forces ‘url` to use HTTPS rather than HTTP. If `url` is already HTTPS, it will happily return `url` unaltered.



19
20
21
# File 'lib/arxiv/string_scrubber.rb', line 19

def self.force_ssl_url(url)
  url.sub(/^http:/, "https:")
end

.scrub(string) ⇒ Object



3
4
5
# File 'lib/arxiv/string_scrubber.rb', line 3

def self.scrub(string)
  string.gsub("\n", ' ').strip.squeeze(" ")
end