Index: packages/path/test/url_test.dart |
diff --git a/packages/path/test/url_test.dart b/packages/path/test/url_test.dart |
index 854e19abd0bb903da404d53f2e5334b009c3decb..c81893a53f4ee50d738b43435e4498bdb2c1e8dd 100644 |
--- a/packages/path/test/url_test.dart |
+++ b/packages/path/test/url_test.dart |
@@ -2,7 +2,7 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-import 'package:unittest/unittest.dart'; |
+import 'package:test/test.dart'; |
import 'package:path/path.dart' as path; |
main() { |
@@ -629,6 +629,31 @@ main() { |
isFalse); |
}); |
+ test('complex cases', () { |
+ expect(context.isWithin('foo/./bar', 'foo/bar/baz'), isTrue); |
+ expect(context.isWithin('foo//bar', 'foo/bar/baz'), isTrue); |
+ expect(context.isWithin('foo/qux/../bar', 'foo/bar/baz'), isTrue); |
+ expect(context.isWithin('foo/bar', 'foo/bar/baz/../..'), isFalse); |
+ expect(context.isWithin('foo/bar', 'foo/bar///'), isFalse); |
+ expect(context.isWithin('foo/.bar', 'foo/.bar/baz'), isTrue); |
+ expect(context.isWithin('foo/./bar', 'foo/.bar/baz'), isFalse); |
+ expect(context.isWithin('foo/..bar', 'foo/..bar/baz'), isTrue); |
+ expect(context.isWithin('foo/bar', 'foo/bar/baz/..'), isFalse); |
+ expect(context.isWithin('foo/bar', 'foo/bar/baz/../qux'), isTrue); |
+ expect(context.isWithin('http://example.org/', 'http://example.com/foo'), |
+ isFalse); |
+ expect(context.isWithin('http://example.org/', 'http://dartlang.org/foo'), |
+ isFalse); |
+ }); |
+ |
+ test('with root-relative paths', () { |
+ expect(context.isWithin('/foo', 'http://dartlang.org/foo/bar'), isTrue); |
+ expect(context.isWithin('http://dartlang.org/foo', '/foo/bar'), isTrue); |
+ expect(context.isWithin('/root', 'foo/bar'), isTrue); |
+ expect(context.isWithin('foo', '/root/path/foo/bar'), isTrue); |
+ expect(context.isWithin('/foo', '/foo/bar'), isTrue); |
+ }); |
+ |
test('from a relative root', () { |
var r = new path.Context(style: path.Style.url, current: 'foo/bar'); |
expect(r.isWithin('.', 'a/b/c'), isTrue); |