| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
| 6 * Holds path information that is used by the WebUI compiler to find files, | 6 * Holds path information that is used by the WebUI compiler to find files, |
| 7 * compute their output location and relative paths between them. | 7 * compute their output location and relative paths between them. |
| 8 */ | 8 */ |
| 9 library web_ui.src.paths; | 9 library web_ui.src.paths; |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 /** | 135 /** |
| 136 * Transforms a [target] url seen in [src] (e.g. a Dart import, a .css href in | 136 * Transforms a [target] url seen in [src] (e.g. a Dart import, a .css href in |
| 137 * an HTML file, etc) into a corresponding url from the output file associated | 137 * an HTML file, etc) into a corresponding url from the output file associated |
| 138 * with [src]. This will keep 'package:', 'dart:', path-absolute, and absolute | 138 * with [src]. This will keep 'package:', 'dart:', path-absolute, and absolute |
| 139 * urls intact, but it will fix relative paths to walk from the output | 139 * urls intact, but it will fix relative paths to walk from the output |
| 140 * directory back to the input directory. An exception will be thrown if | 140 * directory back to the input directory. An exception will be thrown if |
| 141 * [target] is not under [_baseDir]. | 141 * [target] is not under [_baseDir]. |
| 142 */ | 142 */ |
| 143 String transformUrl(String src, String target) { | 143 String transformUrl(String src, String target) { |
| 144 if (new Uri.fromString(target).isAbsolute) return target; | 144 if (Uri.parse(target).isAbsolute) return target; |
| 145 if (path.isAbsolute(target)) return target; | 145 if (path.isAbsolute(target)) return target; |
| 146 return toUrl(path.normalize(path.relative( | 146 return toUrl(path.normalize(path.relative( |
| 147 path.join(path.dirname(src), target), from: outputDirPath(src)))); | 147 path.join(path.dirname(src), target), from: outputDirPath(src)))); |
| 148 } | 148 } |
| 149 | 149 |
| 150 /** Convert a OS specific path into a url. */ | 150 /** Convert a OS specific path into a url. */ |
| 151 static String toUrl(String relPath) => | 151 static String toUrl(String relPath) => |
| 152 (path.separator == '/') ? relPath : path.split(relPath).join('/'); | 152 (path.separator == '/') ? relPath : path.split(relPath).join('/'); |
| 153 } | 153 } |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * Returns a "mangled" name, with a prefix and [suffix] depending on the | 156 * Returns a "mangled" name, with a prefix and [suffix] depending on the |
| 157 * compiler's settings. [forceSuffix] causes [suffix] to be appended even if | 157 * compiler's settings. [forceSuffix] causes [suffix] to be appended even if |
| 158 * the compiler is not mangling names. | 158 * the compiler is not mangling names. |
| 159 */ | 159 */ |
| 160 typedef String NameMangler(String name, String suffix, [bool forceSuffix]); | 160 typedef String NameMangler(String name, String suffix, [bool forceSuffix]); |
| OLD | NEW |