Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: pkg/path/test/url_test.dart

Issue 59483008: Add isWithin to pkg/path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/path/test/relative_test.dart ('k') | pkg/path/test/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/path/test/url_test.dart
diff --git a/pkg/path/test/url_test.dart b/pkg/path/test/url_test.dart
index d43e88c42ccbf6803e2fe066ddead0f13099a2e2..9fb6f0793a730d0bdc64ecc79eff665e24f116eb 100644
--- a/pkg/path/test/url_test.dart
+++ b/pkg/path/test/url_test.dart
@@ -615,6 +615,39 @@ main() {
});
});
+ group('isWithin', () {
+ test('simple cases', () {
+ expect(builder.isWithin('foo/bar', 'foo/bar'), isFalse);
+ expect(builder.isWithin('foo/bar', 'foo/bar/baz'), isTrue);
+ expect(builder.isWithin('foo/bar', 'foo/baz'), isFalse);
+ expect(builder.isWithin('foo/bar', '../path/foo/bar/baz'), isTrue);
+ expect(builder.isWithin(
+ 'http://dartlang.org', 'http://dartlang.org/foo/bar'),
+ isTrue);
+ expect(builder.isWithin(
+ 'http://dartlang.org', 'http://pub.dartlang.org/foo/bar'),
+ isFalse);
+ expect(builder.isWithin('http://dartlang.org', '/foo/bar'), isTrue);
+ expect(builder.isWithin('http://dartlang.org/foo', '/foo/bar'), isTrue);
+ expect(builder.isWithin('http://dartlang.org/foo', '/bar/baz'), isFalse);
+ expect(builder.isWithin('baz', 'http://dartlang.org/root/path/baz/bang'),
+ isTrue);
+ expect(builder.isWithin('baz', 'http://dartlang.org/root/path/bang/baz'),
+ isFalse);
+ });
+
+ test('from a relative root', () {
+ var r = new path.Builder(style: path.Style.url, root: 'foo/bar');
+ expect(builder.isWithin('.', 'a/b/c'), isTrue);
+ expect(builder.isWithin('.', '../a/b/c'), isFalse);
+ expect(builder.isWithin('.', '../../a/foo/b/c'), isFalse);
+ expect(builder.isWithin(
+ 'http://dartlang.org/', 'http://dartlang.org/baz/bang'),
+ isTrue);
+ expect(builder.isWithin('.', 'http://dartlang.org/baz/bang'), isFalse);
+ });
+ });
+
group('resolve', () {
test('allows up to seven parts', () {
expect(builder.resolve('a'), 'http://dartlang.org/root/path/a');
« no previous file with comments | « pkg/path/test/relative_test.dart ('k') | pkg/path/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698