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

Unified Diff: pkg/http_server/lib/src/virtual_directory.dart

Issue 370753002: Fix links of VirtualDirectory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months 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 | « no previous file | pkg/http_server/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http_server/lib/src/virtual_directory.dart
diff --git a/pkg/http_server/lib/src/virtual_directory.dart b/pkg/http_server/lib/src/virtual_directory.dart
index f34baeaa5a3f5188a870211e02f494a81df342fc..bf4e1a5a1010b099a52b843d0858e017cbcf1f02 100644
--- a/pkg/http_server/lib/src/virtual_directory.dart
+++ b/pkg/http_server/lib/src/virtual_directory.dart
@@ -286,14 +286,17 @@ $server
response.write(header);
- void add(String name, String modified, var size) {
- try {
+ void add(String name, String modified, var size, bool folder) {
if (size == null) size = "-";
if (modified == null) modified = "";
var encodedSize = new HtmlEscape().convert(size.toString());
var encodedModified = new HtmlEscape().convert(modified);
var encodedLink = new HtmlEscape(HtmlEscapeMode.ATTRIBUTE)
- .convert(Uri.encodeComponent(normalize(join(path, name))));
+ .convert(Uri.encodeComponent(name));
+ if (folder) {
+ encodedLink += '/';
+ name += '/';
+ }
var encodedName = new HtmlEscape().convert(name);
var entry =
@@ -303,25 +306,25 @@ $server
<td style="text-align: right">$encodedSize</td>
</tr>''';
response.write(entry);
- } catch (e) {
- print(e);
- }
}
if (path != '/') {
- add('../', null, null);
+ add('..', null, null, true);
}
dir.list(followLinks: true).listen((entity) {
+ var name = basename(entity.path);
+ var stat = entity.statSync();
if (entity is File) {
- var stat = entity.statSync();
- add(basename(entity.path),
+ add(name,
stat.modified.toString(),
- stat.size);
+ stat.size,
+ false);
} else if (entity is Directory) {
- add(basename(entity.path) + '/',
- entity.statSync().modified.toString(),
- null);
+ add(name,
+ stat.modified.toString(),
+ null,
+ true);
}
}, onError: (e) {
// TODO(kevmoo): log error
« no previous file with comments | « no previous file | pkg/http_server/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698