Sha256: d51fdb3413e2249623d24f81d60a8021b5f94edc11ee2733aa5907436ec9fe9d

Contents?: true

Size: 849 Bytes

Versions: 8

Compression:

Stored size: 849 Bytes

Contents

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

    # 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.
    #
    def self.force_ssl_url(url)
      url.sub(/^http:/, "https:")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arxiv-0.1.11 lib/arxiv/string_scrubber.rb
arxiv-0.1.10 lib/arxiv/string_scrubber.rb
arxiv-0.1.9 lib/arxiv/string_scrubber.rb
arxiv-0.1.8 lib/arxiv/string_scrubber.rb
arxiv-0.1.7 lib/arxiv/string_scrubber.rb
arxiv-0.1.6 lib/arxiv/string_scrubber.rb
arxiv-0.1.5 lib/arxiv/string_scrubber.rb
arxiv-0.1.4 lib/arxiv/string_scrubber.rb