| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.utilities.dart; | 8 library engine.utilities.dart; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 final bool isOptional; | 31 final bool isOptional; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Initialize a newly created kind with the given state. | 34 * Initialize a newly created kind with the given state. |
| 35 * | 35 * |
| 36 * @param isOptional `true` if this is an optional parameter | 36 * @param isOptional `true` if this is an optional parameter |
| 37 */ | 37 */ |
| 38 const ParameterKind(String name, int ordinal, this.isOptional) | 38 const ParameterKind(String name, int ordinal, this.isOptional) |
| 39 : super(name, ordinal); | 39 : super(name, ordinal); |
| 40 } | 40 } |
| 41 | |
| 42 /** | |
| 43 * Check whether [uri1] starts with (or 'is prefixed by') [uri2] by checking | |
| 44 * path segments. | |
| 45 */ | |
| 46 bool startsWith(Uri uri1, Uri uri2) { | |
| 47 List<String> uri1Segments = uri1.pathSegments; | |
| 48 List<String> uri2Segments = uri2.pathSegments.toList(); | |
| 49 | |
| 50 // Trim trailing empty segments ('/foo/' => ['foo', '']) | |
| 51 if (uri2Segments.last == '') { | |
| 52 uri2Segments.removeLast(); | |
| 53 } | |
| 54 | |
| 55 if (uri2Segments.length > uri1Segments.length) { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 for (int i = 0; i < uri2Segments.length; ++i) { | |
| 60 if (uri2Segments[i] != uri1Segments[i]) { | |
| 61 return false; | |
| 62 } | |
| 63 } | |
| 64 return true; | |
| 65 } | |
| OLD | NEW |