diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8a1e35..701b3155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.1.1 +* URI-encode paths in directory listing. This produces correct URL's, always. + # 2.1.0 * Include support for the `Range` header. * Use MD5 for etags, instead of a weak ETag. diff --git a/lib/src/virtual_directory.dart b/lib/src/virtual_directory.dart index db74049e..a4fa4b93 100644 --- a/lib/src/virtual_directory.dart +++ b/lib/src/virtual_directory.dart @@ -72,7 +72,7 @@ class VirtualDirectory { Future handleRequest(RequestContext req, ResponseContext res) { if (req.method != 'GET' && req.method != 'HEAD') return new Future.value(true); - var path = req.path.replaceAll(_straySlashes, ''); + var path = req.uri.path.replaceAll(_straySlashes, ''); if (_prefix?.isNotEmpty == true && !path.startsWith(_prefix)) return new Future.value(true); @@ -196,6 +196,7 @@ class VirtualDirectory { if (relative.isNotEmpty) href = '/' + relative + '/' + stub; if (entity is Directory) href += '/'; + href = Uri.encodeFull(href); res.write('
  • $type $stub
  • '); } diff --git a/pubspec.yaml b/pubspec.yaml index a71aa605..d51c1082 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ environment: sdk: ">=1.8.0 <3.0.0" homepage: https://github.com/angel-dart/static author: Tobe O -version: 2.1.0 +version: 2.1.1 dependencies: angel_framework: ^2.0.0-alpha convert: ^2.0.0