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

Unified Diff: lib/src/util/one_off_handler.dart

Issue 1076803003: Change the URL-space exposed by the browser server. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Changelog + pubspec Created 5 years, 8 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
Index: lib/src/util/one_off_handler.dart
diff --git a/lib/src/util/one_off_handler.dart b/lib/src/util/one_off_handler.dart
index 069d6818875d0d4028f022be2d5060cd2537d61a..442a76486590504b3c606904899641d2be525290 100644
--- a/lib/src/util/one_off_handler.dart
+++ b/lib/src/util/one_off_handler.dart
@@ -2,11 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library test.one_off_handler;
+library test.util.one_off_handler;
import 'package:path/path.dart' as p;
import 'package:shelf/shelf.dart' as shelf;
+import '../utils.dart';
+
/// A Shelf handler that provides support for one-time handlers.
///
/// This is useful for handlers that only expect to be hit once before becoming
@@ -36,18 +38,12 @@ class OneOffHandler {
/// Dispatches [request] to the appropriate handler.
_onRequest(shelf.Request request) {
- var components = p.url.split(request.url.path);
-
- // For shelf < 0.6.0, the first component of the path is always "/". We can
- // safely skip it.
- if (components.isNotEmpty && components.first == "/") {
- components.removeAt(0);
- }
-
+ var components = p.url.split(shelfUrl(request).path);
if (components.isEmpty) return new shelf.Response.notFound(null);
- var handler = _handlers.remove(components.removeAt(0));
+ var path = components.removeAt(0);
+ var handler = _handlers.remove(path);
if (handler == null) return new shelf.Response.notFound(null);
- return handler(request);
+ return handler(shelfChange(request, path: path));
}
}

Powered by Google App Engine
This is Rietveld 408576698