Sha256: 55eff4583807054b2fb63d650c5331e5c55caf1ede3b5505241d22e6929548fd

Contents?: true

Size: 901 Bytes

Versions: 41

Compression:

Stored size: 901 Bytes

Contents

module Middleman
  class PreviewServer
    class ServerHostname
      class ServerFullHostname < SimpleDelegator
        def to_s
          __getobj__.gsub(/\s/, '+')
        end

        def self.match?(*)
          true
        end

        alias to_browser to_s
      end

      class ServerPlainHostname < SimpleDelegator
        def to_s
          __getobj__.gsub(/\s/, '+') + '.local'
        end

        def self.match?(name)
          # rubocop:disable Style/CaseEquality
          name != 'localhost' && /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?\.?$/ === name
          # rubocop:enable Style/CaseEquality
        end

        alias to_browser to_s
      end

      def self.new(string)
        @names = []
        @names << ServerPlainHostname
        @names << ServerFullHostname

        @names.find { |n| n.match? string }.new(string)
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 3 rubygems

Version Path
middleman-core-4.5.1 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.5.0 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.4.3 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.4.2 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.4.0 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.11 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.10 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.8 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.7 lib/middleman-core/preview_server/server_hostname.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-core-4.3.3/lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.6 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.5 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-5.0.0.rc.1 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.4 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.3 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.2 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.1 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.0 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.0.rc.4 lib/middleman-core/preview_server/server_hostname.rb
middleman-core-4.3.0.rc.3 lib/middleman-core/preview_server/server_hostname.rb