Normalize a path

@param   string $path path

@return  string  normalized path
321431
public static function normalize(string $path): string {
		if (!(false === strpos($path, '://'))) {
			$ex = explode("://", $path);

			return $ex[0] . "://" . "/" . ltrim(Util::normalizePath("/" . ltrim($ex[1], "/")));
		}

		return "/" . ltrim(Util::normalizePath($path), "/");
	}
890372
private function normalizePath($path, $removeTrailingSeparator = false)
    {
        $newPath = str_replace('/', DIRECTORY_SEPARATOR, $path);
        $newPath = str_replace('\\', DIRECTORY_SEPARATOR, $newPath);

        $newPath = str_replace(':'.DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, '://', $newPath);

        if ($removeTrailingSeparator) {
            return rtrim($newPath, DIRECTORY_SEPARATOR);
        }

        return $newPath;
    }
301557
private function encodePath($path)
    {
        $path = $this->normalisePath($path);
        $path = str_replace('%2F', '/', rawurlencode($path));
        return $path;
    }
768264
protected static function normalizePath($path)
    {
        if ('/' === substr($path, 0, 1)) {
            $path = static::removePathDotSegments($path);
        }

        $path = static::encodePath(
            static::decodeUrlEncodedChars(
                $path,
                '/[' . static::CHAR_UNRESERVED . ':@&=\+\$,\/;%]/'
            )
        );

        if (strlen($path) > 1 && '/' === substr($path, -1)) {
            $path = substr($path, 0, -1);
        }

        return $path;
    }
38645
protected function normalizePath($path)
    {
        $path = parent::normalizePath($path);
        return $this->getMultiRepositoryPath($path) ?: $path;
    }
846139
protected static String normalizePath (String path) {
    int pathLen;
    do {
      pathLen = path.length();
      path = path.replaceAll("[^/]+/\\.\\./", "");
    } while (path.length() != pathLen);
    return path;
  }
869464
public static function normalizePath($path) : string
    {
        $path = self::fixDirectorySeparator($path);
        $path = preg_replace('|(?<=.)/+|', DIRECTORY_SEPARATOR, $path);
        if (':' === substr($path, 1, 1)) {
            $path = ucfirst($path);
        }

        if (Validator::isAbsolutePath($path) && strpos($path, '.')) {
            $explode = explode(DIRECTORY_SEPARATOR, $path);
            $array = [];
            foreach ($explode as $key => $value) {
                if ('.' == $value) {
                    continue;
                }
                if ('..' == $value) {
                    array_pop($array);
                } else {
                    $array[] = $value;
                }
            }

            $path = implode(DIRECTORY_SEPARATOR, $array);
        }

        return $path;
    }
109151
private function normalizePath(): string
    {
        $path = $this->path;
        if (substr($path, -1) === '$') {
            $path = substr($path, 0, strlen($path) - 1);
        }

        if (substr($path, -1) === '?') {
            $path = substr($path, 0, strlen($path) - 1);
        }

        return $path;
    }
971238
public function path($path)
    {
        $path  = strtolower(trim($path));
        $first = substr($path, 0, 1);
        
        if ($first == '@' && isset($this->aliases[$path])) {
            $path = $this->aliases[$path];
            
        } elseif ($first == '/') {
            $path = preg_replace('/\\//', $this->root() . '/', $path, 1);
            
        }
        if ($path = realpath($path)) {
            $path = static::clean($path);
        }
        
        return $path;
    }
564242
public static function normalizePath($path)
    {
        $path = rtrim($path, '/');
        $path = rtrim($path, '\\');
        $path .= DIRECTORY_SEPARATOR;
        return $path;
    }
1224834
private static function normalizePaths($paths) {
    $re = ['#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'];
    for ($n=1; $n>0; $paths=preg_replace($re, '/', $paths, -1, $n)) {}
    return $paths;
  }
1154902
protected function _relativizePath($path)
    {
        $plugins = Plugin::loaded();
        $index = array_search('AssetCompress', $plugins);
        unset($plugins[$index]);

        foreach ($plugins as $plugin) {
            $pluginPath = Plugin::path($plugin) . 'webroot';
            if (strpos($path, $pluginPath) === 0) {
                return str_replace($pluginPath, '/' . Inflector::underscore($plugin), $path);
            }
        }
        $path = str_replace(WWW_ROOT, '/', $path);

        return str_replace(DS, '/', $path);
    }
684801
public static String normalizePath(String path) {
    String normalizedPath = path.replaceAll("//+", "/").replaceFirst("(.+)/$", "$1");
    PathUtils.validatePath(normalizedPath);
    return normalizedPath;
  }
320523
public function resolveFullPath($path)
    {
        if (is_array($path)) {
            $paths  = array();
            foreach ($path as $p) {
                $paths[]    = $this->resolveFullPath($p);
            }
            return $paths;
        } else {
            if (strpos($path, $this->getRepositoryPath()) === 0) {
                return $path;
            }
            $path  = FileSystem::normalizeDirectorySeparator($path);
            $path  = ltrim($path, '/');
            return $this->getRepositoryPath().'/'.$path;
        }
    }
626702
public static function normalize(string $path):string
    {
        $path = str_replace('\\', '/', $path);
        $prefix = static::prefix($path);
        $path = substr($path, strlen($prefix));
        $parts = array_filter(explode('/', $path), 'strlen');
        $tokens = array();
        foreach ($parts as $part) {
            switch ($part) {
                case '.':
                    break;
                case '..':
                    if (0 !== count($tokens)) {
                        array_pop($tokens);
                    }

                    break;
                default:
                    $tokens[] = $part;
            }
        }
        return $prefix . implode('/', $tokens);
    }
180140
public static function Normalize( string $path ) : string
   {

      if ( empty( static::$NoFolderSeparator ) )
      {
         static::$NoFolderSeparator = File::IS_WIN ? '/' : '\\';
      }

      $tmpPath = ( File::IS_WIN
         ? \trim(
            \str_replace(
               static::$NoFolderSeparator,
               \DIRECTORY_SEPARATOR,
               $path
            ),
            \DIRECTORY_SEPARATOR
         )
         : \rtrim(
            \str_replace(
               static::$NoFolderSeparator,
               \DIRECTORY_SEPARATOR,
               $path
            ),
            \DIRECTORY_SEPARATOR
         )
      );

      // return the resulting path and replace /./ or \.\ with a single directory separator
      return str_replace(
         \DIRECTORY_SEPARATOR . '.' . \DIRECTORY_SEPARATOR,
         \DIRECTORY_SEPARATOR,
         $tmpPath
      );

   }
906192
protected function sanitizePath($path)
    {
        if (empty($path)) {
            return '';
        }

        $path = Files::getUnixStylePath($path);
        if (is_dir($path)) {
            $path = Files::getNormalizedPath($path);
        }

        return $path;
    }