Sha256: 96ce87c0b5e5966987acb6dbf93bbece0af93edf82981c9ddb06842c9c41532b

Contents?: true

Size: 675 Bytes

Versions: 5

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true
class SourceforgeUrlParser < URLParser
  PROJECT_PATHS = %w[projects p].freeze

  private

  def full_domain
    'https://sourceforge.net/projects'
  end

  def tlds
    %w(net)
  end

  def domain
    'sourceforge'
  end

  def remove_domain
    url.sub!(/(sourceforge\.net\/(#{PROJECT_PATHS.join("|")}))+?(:|\/)?/i, '')
  end

  def extractable_early?
    false
  end

  def remove_extra_segments
    self.url = url.split('/').reject{ |s| s.strip.empty? }.first
  end

  def format_url
    # the URL at this point should have been reduced down to a single string for the project name
    return nil unless url.is_a?(String)

    url
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
librariesio-url-parser-1.0.10 lib/sourceforge_url_parser.rb
librariesio-url-parser-1.0.9 lib/sourceforge_url_parser.rb
librariesio-url-parser-1.0.8 lib/sourceforge_url_parser.rb
librariesio-url-parser-1.0.7 lib/sourceforge_url_parser.rb
librariesio-url-parser-1.0.6 lib/sourceforge_url_parser.rb