| OLD | NEW |
| 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 hosted_source; | 5 library hosted_source; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 /// The system cache directory for the hosted source contains subdirectories | 90 /// The system cache directory for the hosted source contains subdirectories |
| 91 /// for each separate repository URL that's used on the system. Each of these | 91 /// for each separate repository URL that's used on the system. Each of these |
| 92 /// subdirectories then contains a subdirectory for each package installed | 92 /// subdirectories then contains a subdirectory for each package installed |
| 93 /// from that site. | 93 /// from that site. |
| 94 Future<String> systemCacheDirectory(PackageId id) { | 94 Future<String> systemCacheDirectory(PackageId id) { |
| 95 var parsed = _parseDescription(id.description); | 95 var parsed = _parseDescription(id.description); |
| 96 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); | 96 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); |
| 97 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { | 97 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { |
| 98 return '%${match[0].charCodeAt(0)}'; | 98 return '%${match[0].codeUnitAt(0)}'; |
| 99 }); | 99 }); |
| 100 | 100 |
| 101 return new Future.immediate( | 101 return new Future.immediate( |
| 102 path.join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}")); | 102 path.join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}")); |
| 103 } | 103 } |
| 104 | 104 |
| 105 String packageName(description) => _parseDescription(description).first; | 105 String packageName(description) => _parseDescription(description).first; |
| 106 | 106 |
| 107 bool descriptionsEqual(description1, description2) => | 107 bool descriptionsEqual(description1, description2) => |
| 108 _parseDescription(description1) == _parseDescription(description2); | 108 _parseDescription(description1) == _parseDescription(description2); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 var name = description["name"]; | 189 var name = description["name"]; |
| 190 if (name is! String) { | 190 if (name is! String) { |
| 191 throw new FormatException("The 'name' key must have a string value."); | 191 throw new FormatException("The 'name' key must have a string value."); |
| 192 } | 192 } |
| 193 | 193 |
| 194 var url = description.containsKey("url") ? description["url"] : _defaultUrl; | 194 var url = description.containsKey("url") ? description["url"] : _defaultUrl; |
| 195 return new Pair<String, String>(name, url); | 195 return new Pair<String, String>(name, url); |
| 196 } | 196 } |
| OLD | NEW |