From 917547487a3773527f8f5512fac6e21764a27493 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 8 Jun 2017 15:16:50 -0700 Subject: [PATCH] Fix a normalization bug. (#26) Closes #24 --- CHANGELOG.md | 4 ++++ lib/src/context.dart | 2 +- pubspec.yaml | 2 +- test/windows_test.dart | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7dde67..67c849c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.4.2 + +* Normalize `c:\foo\.` to `c:\foo`. + ## 1.4.1 * Root-relative URLs like `/foo` are now resolved relative to the drive letter diff --git a/lib/src/context.dart b/lib/src/context.dart index c5ebb69..a00ca29 100644 --- a/lib/src/context.dart +++ b/lib/src/context.dart @@ -397,7 +397,7 @@ class Context { // Single dots and double dots are normalized to directory traversals. if (previous == chars.PERIOD && (previousPrevious == null || - previousPrevious == chars.SLASH || + style.isSeparator(previousPrevious) || previousPrevious == chars.PERIOD)) { return true; } diff --git a/pubspec.yaml b/pubspec.yaml index 48e799b..ff101d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: path -version: 1.4.1 +version: 1.4.2-dev author: Dart Team description: > A string-based path manipulation library. All of the path operations you know diff --git a/test/windows_test.dart b/test/windows_test.dart index ad58774..364db34 100644 --- a/test/windows_test.dart +++ b/test/windows_test.dart @@ -330,6 +330,7 @@ main() { test('eliminates "." parts', () { expect(context.normalize(r'.\'), '.'); expect(context.normalize(r'c:\.'), r'c:\'); + expect(context.normalize(r'c:\foo\.'), r'c:\foo'); expect(context.normalize(r'B:\.\'), r'B:\'); expect(context.normalize(r'\\server\share\.'), r'\\server\share'); expect(context.normalize(r'.\.'), '.'); @@ -351,6 +352,7 @@ main() { expect( context.normalize(r'\\server\share\..\../..\a'), r'\\server\share\a'); expect(context.normalize(r'c:\..'), r'c:\'); + expect(context.normalize(r'c:\foo\..'), r'c:\'); expect(context.normalize(r'A:/..\..\..'), r'A:\'); expect(context.normalize(r'b:\..\..\..\a'), r'b:\a'); expect(context.normalize(r'b:\r\..\..\..\a\c\.\..'), r'b:\a');