Ejemplo n.º 1
0
        public static string DecodeAndUnescapePath(Span <byte> rawUrlBytes)
        {
            Debug.Assert(rawUrlBytes.Length > 0, "Length of the URL cannot be zero.");
            var rawPath = RawUrlHelper.GetPath(rawUrlBytes);

            if (rawPath.Length == 0)
            {
                return("/");
            }

            var unescapedPath = Unescape(rawPath);

            return(UTF8.GetString(unescapedPath));
        }
Ejemplo n.º 2
0
        public static string DecodeAndUnescapePath(Span <byte> rawUrlBytes)
        {
            Debug.Assert(rawUrlBytes.Length != 0, "Length of the URL cannot be zero.");
            var rawPath = RawUrlHelper.GetPath(rawUrlBytes);

            if (rawPath.Length == 0)
            {
                return("/");
            }

            var unescapedPath = Unescape(rawPath);

            var length = PathNormalizer.RemoveDotSegments(unescapedPath);

            return(UTF8.GetString(unescapedPath.Slice(0, length)));
        }
Ejemplo n.º 3
0
        public static string DecodeAndUnescapePath(byte[] rawUrlBytes)
        {
            if (rawUrlBytes == null)
            {
                throw new ArgumentNullException(nameof(rawUrlBytes));
            }

            if (rawUrlBytes.Length == 0)
            {
                throw new ArgumentException("Length of the URL cannot be zero.", nameof(rawUrlBytes));
            }

            var rawPath = RawUrlHelper.GetPath(rawUrlBytes);

            var unescapedPath = Unescape(rawPath);

            return(UTF8.GetString(unescapedPath.Array, unescapedPath.Offset, unescapedPath.Count));
        }
Ejemplo n.º 4
0
        public static string DecodeAndUnescapePath(Span <byte> rawUrlBytes)
        {
            Debug.Assert(rawUrlBytes.Length != 0, "Length of the URL cannot be zero.");
            var rawPath = RawUrlHelper.GetPath(rawUrlBytes);

            if (rawPath.Length == 0)
            {
                return("/");
            }

            // OPTIONS *
            // RemoveDotSegments Asserts path always starts with a '/'
            if (rawPath.Length == 1 && rawPath[0] == (byte)'*')
            {
                return("*");
            }

            var unescapedPath = Unescape(rawPath);

            var length = PathNormalizer.RemoveDotSegments(unescapedPath);

            return(UTF8.GetString(unescapedPath.Slice(0, length)));
        }