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

Side by Side Diff: pkg/oauth2/lib/src/utils.dart

Issue 12021022: Stop supporting map literals with 1 type argument (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:uri'; 8 import 'dart:uri';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:crypto'; 10 import 'dart:crypto';
11 11
12 /// Adds additional query parameters to [url], overwriting the original 12 /// Adds additional query parameters to [url], overwriting the original
13 /// parameters if a name conflict occurs. 13 /// parameters if a name conflict occurs.
14 Uri addQueryParameters(Uri url, Map<String, String> parameters) { 14 Uri addQueryParameters(Uri url, Map<String, String> parameters) {
15 var queryMap = queryToMap(url.query); 15 var queryMap = queryToMap(url.query);
16 mapAddAll(queryMap, parameters); 16 mapAddAll(queryMap, parameters);
17 return url.resolve("?${mapToQuery(queryMap)}"); 17 return url.resolve("?${mapToQuery(queryMap)}");
18 } 18 }
19 19
20 /// Convert a URL query string (or `application/x-www-form-urlencoded` body) 20 /// Convert a URL query string (or `application/x-www-form-urlencoded` body)
21 /// into a [Map] from parameter names to values. 21 /// into a [Map] from parameter names to values.
22 Map<String, String> queryToMap(String queryList) { 22 Map<String, String> queryToMap(String queryList) {
23 var map = <String>{}; 23 var map = <String, String>{};
24 for (var pair in queryList.split("&")) { 24 for (var pair in queryList.split("&")) {
25 var split = split1(pair, "="); 25 var split = split1(pair, "=");
26 if (split.isEmpty) continue; 26 if (split.isEmpty) continue;
27 var key = urlDecode(split[0]); 27 var key = urlDecode(split[0]);
28 var value = split.length > 1 ? urlDecode(split[1]) : ""; 28 var value = split.length > 1 ? urlDecode(split[1]) : "";
29 map[key] = value; 29 map[key] = value;
30 } 30 }
31 return map; 31 return map;
32 } 32 }
33 33
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!paramString.trim().isEmpty) { 107 if (!paramString.trim().isEmpty) {
108 throw new FormatException('Invalid WWW-Authenticate header: "$header"'); 108 throw new FormatException('Invalid WWW-Authenticate header: "$header"');
109 } 109 }
110 110
111 return new AuthenticateHeader(scheme, parameters); 111 return new AuthenticateHeader(scheme, parameters);
112 } 112 }
113 } 113 }
114 114
115 /// Returns a [Future] that asynchronously completes to `null`. 115 /// Returns a [Future] that asynchronously completes to `null`.
116 Future get async => new Future.delayed(0, () => null); 116 Future get async => new Future.delayed(0, () => null);
OLDNEW
« no previous file with comments | « pkg/http/test/utils.dart ('k') | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698