public static function escapeDateMath($requestUri)
    {
        if (empty($requestUri)) {
            return $requestUri;
        }

        // Check if date math if used at all. Find last '>'. E.g. /<log-{now/d}>,log-2011.12.01/log/_refresh
        $pos1 = \strrpos($requestUri, '>');
        if (false === $pos1) {
            return $requestUri;
        }

        // Find the position up to which we should escape.
        // Should be next slash '/' after last '>' E.g. /<log-{now/d}>,log-2011.12.01/log/_refresh
        $pos2 = \strpos($requestUri, '/', $pos1);
        $pos2 = false !== $pos2 ? $pos2 : \strlen($requestUri);

        // Cut out the bit we need to escape: /<log-{now/d}>,log-2011.12.01
        $uriSegment = \substr($requestUri, 0, $pos2);

        // Escape using character map
        $escapedUriSegment = \str_replace(static::$dateMathSymbols, static::$escapedDateMathSymbols, $uriSegment);

        // '\\{' and '\\}' should not be escaped
        if (false !== \strpos($uriSegment, '\\\\')) {
            $escapedUriSegment = \str_replace(['\\\\%7B', '\\\\%7D'], ['\\\\{', '\\\\}'], $escapedUriSegment);
        }

        // Replace part of the string. E.g. /%3Clog-%7Bnow%2Fd%7D%3E%2Clog-2011.12.01/log/_refresh
        return \substr_replace($requestUri, $escapedUriSegment, 0, $pos2);
    }