Module: Aikido::Zen::Helpers Private

Defined in:
lib/aikido/zen/helpers.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.normalize_path(path) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Normalizes a path by:

1. Collapsing consecutive forward slashes into a single forward slash.
2. Removing forward trailing slash, unless the normalized path is "/".

Parameters:

  • path (String, nil)

    the path to normalize.

Returns:

  • (String, nil)

    the normalized path.



14
15
16
17
18
19
20
21
# File 'lib/aikido/zen/helpers.rb', line 14

def self.normalize_path(path)
  return path unless path

  normalized_path = path.dup
  normalized_path.squeeze!("/")
  normalized_path.chomp!("/") unless normalized_path == "/"
  normalized_path
end