 |
Changeset 3057
- Timestamp:
- 12/20/07 08:17:18
(1 year ago)
- Author:
- larsivi
- Message:
Fixed normalize to work with files starting with a dot. Thanks bobef.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3050 |
r3057 |
|
| 157 | 157 | } |
|---|
| 158 | 158 | } |
|---|
| | 159 | else { |
|---|
| | 160 | if (findSlash(path, path.length - 1) < start) |
|---|
| | 161 | // segment is filename that starts with ., and at the end |
|---|
| | 162 | return path; |
|---|
| | 163 | else { |
|---|
| | 164 | // not at end |
|---|
| | 165 | int idx = findSlashDot(path, start); |
|---|
| | 166 | if (idx > -1) |
|---|
| | 167 | return removeDots(path, idx); |
|---|
| | 168 | else |
|---|
| | 169 | return path; |
|---|
| | 170 | } |
|---|
| | 171 | } |
|---|
| 159 | 172 | assert(false, "PathUtil :: invalid code path"); |
|---|
| 160 | 173 | } |
|---|
| … | … | |
| 184 | 197 | unittest |
|---|
| 185 | 198 | { |
|---|
| 186 | | assert (normalize ("foo/bar/././.") == "foo/bar", normalize ("foo/bar/././.")); |
|---|
| 187 | | assert (normalize ("././foo/././././bar") == "foo/bar", normalize ("././foo/././././bar")); |
|---|
| 188 | | assert (normalize ("/foo/../john") == "/john", normalize("/foo/../john")); |
|---|
| | 199 | assert (normalize ("/home/../john/../.tango/.htaccess") == "/.tango/.htaccess", |
|---|
| | 200 | normalize ("/home/../john/../.tango/.htaccess")); |
|---|
| | 201 | assert (normalize ("/home/../john/../.tango/foo.conf") == "/.tango/foo.conf", |
|---|
| | 202 | normalize ("/home/../john/../.tango/foo.conf")); |
|---|
| | 203 | assert (normalize ("/home/john/.tango/foo.conf") == "/home/john/.tango/foo.conf", |
|---|
| | 204 | normalize ("/home/john/.tango/foo.conf")); |
|---|
| | 205 | assert (normalize ("/foo/bar/.htaccess") == "/foo/bar/.htaccess", |
|---|
| | 206 | normalize ("/foo/bar/.htaccess")); |
|---|
| | 207 | assert (normalize ("foo/bar/././.") == "foo/bar", |
|---|
| | 208 | normalize ("foo/bar/././.")); |
|---|
| | 209 | assert (normalize ("././foo/././././bar") == "foo/bar", |
|---|
| | 210 | normalize ("././foo/././././bar")); |
|---|
| | 211 | assert (normalize ("/foo/../john") == "/john", |
|---|
| | 212 | normalize("/foo/../john")); |
|---|
| 189 | 213 | assert (normalize ("foo/../john") == "john"); |
|---|
| 190 | 214 | assert (normalize ("foo/bar/..") == "foo"); |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic