File: format.rb

package info (click to toggle)
ruby-mdurl-rb 1.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 156 kB
  • sloc: ruby: 1,077; makefile: 7
file content (28 lines) | stat: -rwxr-xr-x 654 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module MDUrl
  module Format

    #------------------------------------------------------------------------------
    def self.format(url)
      result = ''

      result += url.protocol || ''
      result += url.slashes ? '//' : ''
      result += url.auth ? url.auth + '@' : ''

      if (url.hostname && url.hostname.index(':') != nil)
        # ipv6 address
        result += '[' + url.hostname + ']'
      else
        result += url.hostname || ''
      end

      result += url.port ? ':' + url.port : ''
      result += url.pathname || ''
      result += url.search || ''
      result += url.hash || ''

      return result
    end
    
  end
end