Module: Docker::API::Path

Defined in:
lib/docker/api/path.rb,
sig/docker/api/core.rbs

Overview

Escaping for values interpolated into a request path.

Constant Summary collapse

SAFE =

Characters that may appear unescaped in a path. This is RFC 3986's pchar set plus the separator itself.

Keeping "/" and ":" unescaped is the point. Image references are registry.example.com/team/image:tag, and the daemon's router matches those slashes as path structure -- percent-encoding them turns a valid reference into a 404. Everything genuinely unsafe (spaces, "?", "#", "%") is still escaped.

Returns:

  • (Regexp)
%r{[^A-Za-z0-9\-._~!$&'()*+,;=:@/]}

Class Method Summary collapse

Class Method Details

.escape(value) ⇒ String

Returns the value, safe to place in a path.

Examples:

Path.escape("registry.io/team/img:1.0") #=> "registry.io/team/img:1.0"
Path.escape("weird name")               #=> "weird%20name"

Parameters:

  • value (Object)

    a value being interpolated into a path

Returns:

  • (String)

    the value, safe to place in a path



28
29
30
# File 'lib/docker/api/path.rb', line 28

def escape(value)
  URI::DEFAULT_PARSER.escape(value.to_s, SAFE)
end