Esempio n. 1
0
        public void RemovesDotSegments(string input, string expected)
        {
            var data   = Encoding.ASCII.GetBytes(input);
            var length = PathNormalizer.RemoveDotSegments(new Span <byte>(data));

            Assert.True(length >= 1);
            Assert.Equal(expected, Encoding.ASCII.GetString(data, 0, length));
        }
Esempio 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)));
        }
Esempio n. 3
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)));
        }