Sha256: e65b78fbdb0d39fc37b06842b34fd767b315b0fdde5bce7117da64df3ef0f9b0
Contents?: true
Size: 682 Bytes
Versions: 13
Compression:
Stored size: 682 Bytes
Contents
# frozen_string_literal: true require "uri" module Hanami module CLI module URL DEFAULT_URL_PREFIX = "/" private_constant :DEFAULT_URL_PREFIX class << self def call(url) result = url result = URI.parse(result).path unless valid?(result) raise ArgumentError.new("invalid URL: `#{url}'") end result rescue URI::InvalidURIError raise ArgumentError.new("invalid URL: `#{url}'") end alias_method :[], :call def valid?(url) return false if url.nil? url.start_with?(DEFAULT_URL_PREFIX) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems