Sha256: 8bc4ad002673eaa73b85d9f0066b8378143d81c44d5ff6261ae48f1862c8cb40

Contents?: true

Size: 717 Bytes

Versions: 14

Compression:

Stored size: 717 Bytes

Contents

module Scrivito
  class ResolvePathsController < WebserviceController
    def resolve
      link_parser = LinkParser.new(request.host, request.port)
      @paths = assert_paths.map do |path|
        link = link_parser.parse(path)
        next if link.external?
        {
          'id' => link.obj.id,
          'query' => link.query,
          'fragment' => link.fragment,
        }
      end
    end

    private

    def assert_paths
      raise ClientError.new('paths is not given or not an Array') unless params[:paths].is_a?(Array)
      unless params[:paths].all? { |path| path.is_a?(String) }
        raise ClientError.new('paths is not an Array of Strings')
      end

      params[:paths]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
scrivito_sdk-1.5.5 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.5.rc1 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.4 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.4.rc1 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.3 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.3.rc1 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.2 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.2.rc1 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.1 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.1.rc2 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.1.rc1 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.0 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.0.rc2 app/controllers/scrivito/resolve_paths_controller.rb
scrivito_sdk-1.5.0.rc1 app/controllers/scrivito/resolve_paths_controller.rb