- Timestamp:
- 2019-11-30T13:44:40+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java
r14389 r15543 6 6 import java.awt.Desktop; 7 7 import java.io.IOException; 8 import java.net.MalformedURLException; 8 9 import java.net.URI; 9 10 import java.net.URISyntaxException; … … 63 64 public static String displayUrl(String url) { 64 65 try { 65 return displayUrl( newURI(url));66 } catch (URISyntaxException e) {66 return displayUrl(Utils.urlToURI(url)); 67 } catch (URISyntaxException | MalformedURLException e) { 67 68 Logging.debug(e); 68 69 return e.getMessage(); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r15293 r15543 12 12 import java.io.IOException; 13 13 import java.io.InputStream; 14 import java.net.URI;15 14 import java.net.URISyntaxException; 16 15 import java.nio.charset.StandardCharsets; … … 69 68 try { 70 69 if ("#DESKTOP#".equals(program)) { 71 Desktop.getDesktop().browse( newURI(url));70 Desktop.getDesktop().browse(Utils.urlToURI(url)); 72 71 } else if (program.startsWith("$")) { 73 72 program = System.getenv().get(program.substring(1)); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r15469 r15543 40 40 import java.io.Writer; 41 41 import java.lang.reflect.InvocationTargetException; 42 import java.net.URI;43 42 import java.net.URISyntaxException; 44 43 import java.nio.charset.StandardCharsets; … … 169 168 try { 170 169 // Desktop API works fine under Windows 171 Desktop.getDesktop().browse( newURI(url));170 Desktop.getDesktop().browse(Utils.urlToURI(url)); 172 171 } catch (IOException | URISyntaxException e) { 173 172 Logging.log(Logging.LEVEL_WARN, "Desktop class failed. Platform dependent fall back for open url in browser.", e); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r15416 r15543 18 18 import java.io.UnsupportedEncodingException; 19 19 import java.net.MalformedURLException; 20 import java.net.URI; 21 import java.net.URISyntaxException; 20 22 import java.net.URL; 21 23 import java.net.URLDecoder; … … 542 544 } 543 545 546 /** 547 * Converts the given URL to its URI. 548 * @param url the URL to get URI from 549 * @return the URI of given URL 550 * @throws URISyntaxException if the URL cannot be converted to an URI 551 * @throws MalformedURLException if no protocol is specified, or an unknown protocol is found, or {@code spec} is {@code null}. 552 * @since 15543 553 */ 554 public static URI urlToURI(String url) throws URISyntaxException, MalformedURLException { 555 return urlToURI(new URL(url)); 556 } 557 558 /** 559 * Converts the given URL to its URI. 560 * @param url the URL to get URI from 561 * @return the URI of given URL 562 * @throws URISyntaxException if the URL cannot be converted to an URI 563 * @since 15543 564 */ 565 public static URI urlToURI(URL url) throws URISyntaxException { 566 try { 567 return url.toURI(); 568 } catch (URISyntaxException e) { 569 Logging.trace(e); 570 return new URI( 571 url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); 572 } 573 } 574 544 575 private static final double EPSILON = 1e-11; 545 576
Note:
See TracChangeset
for help on using the changeset viewer.