| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
| 3 * | 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * | 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * | 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public static String eclipseUrlToVm(String url) { | 32 public static String eclipseUrlToVm(String url) { |
| 33 // file:/ --> file:/// | 33 // file:/ --> file:/// |
| 34 | 34 |
| 35 if (url == null) { | 35 if (url == null) { |
| 36 return null; | 36 return null; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Use the URI class to convert things like '%20' ==> ' '. | 39 // Use the URI class to convert things like '%20' ==> ' '. |
| 40 URI uri = URI.create(url); | 40 URI uri = URI.create(url); |
| 41 | 41 |
| 42 // If there's no provided uri scheme, then return the original url. |
| 43 if (uri.getScheme() == null) { |
| 44 return url; |
| 45 } |
| 46 |
| 42 if (url.startsWith(ECLIPSE_FORMAT)) { | 47 if (url.startsWith(ECLIPSE_FORMAT)) { |
| 43 // The VM also wants file urls to start with file:///, not file:/. | 48 // The VM also wants file urls to start with file:///, not file:/. |
| 44 url = uri.getScheme() + "://" + uri.getPath(); | 49 url = uri.getScheme() + "://" + uri.getPath(); |
| 45 } else { | 50 } else { |
| 46 url = uri.getScheme() + ":" + uri.getSchemeSpecificPart(); | 51 url = uri.getScheme() + ":" + uri.getSchemeSpecificPart(); |
| 47 } | 52 } |
| 48 | 53 |
| 49 return url; | 54 return url; |
| 50 } | 55 } |
| 51 | 56 |
| 52 /** | 57 /** |
| 53 * Convert the given URL from VM format (file:///) to Eclipse format (file:/). | 58 * Convert the given URL from VM format (file:///) to Eclipse format (file:/). |
| 54 */ | 59 */ |
| 55 public static String vmUrlToEclipse(String url) { | 60 public static String vmUrlToEclipse(String url) { |
| 56 if (url == null) { | 61 if (url == null) { |
| 57 return null; | 62 return null; |
| 58 } | 63 } |
| 59 | 64 |
| 60 if (url.startsWith(VM_FORMAT)) { | 65 if (url.startsWith(VM_FORMAT)) { |
| 61 url = ECLIPSE_FORMAT + url.substring(VM_FORMAT.length()); | 66 url = ECLIPSE_FORMAT + url.substring(VM_FORMAT.length()); |
| 62 } | 67 } |
| 63 | 68 |
| 64 url = URIUtilities.uriEncode(url); | 69 url = URIUtilities.uriEncode(url); |
| 65 | 70 |
| 66 return url; | 71 return url; |
| 67 } | 72 } |
| 68 } | 73 } |
| OLD | NEW |