equal
deleted
inserted
replaced
37 exn.isInstanceOf[URISyntaxException] || |
37 exn.isInstanceOf[URISyntaxException] || |
38 exn.isInstanceOf[IllegalArgumentException] |
38 exn.isInstanceOf[IllegalArgumentException] |
39 |
39 |
40 def apply(uri: URI): Url = new Url(uri) |
40 def apply(uri: URI): Url = new Url(uri) |
41 |
41 |
42 def apply(name: String): Url = { |
42 def apply(name: String): Url = |
43 val uri = |
43 try { new Url(new URI(name)) } |
44 try { new URI(name) } |
44 catch { |
45 catch { |
45 case exn: Throwable if is_malformed(exn) => error("Malformed URL " + quote(name)) |
46 case exn: Throwable if is_malformed(exn) => error("Malformed URL " + quote(name)) |
46 } |
47 } |
|
48 Url(uri) |
|
49 } |
|
50 |
47 |
51 def is_wellformed(name: String): Boolean = |
48 def is_wellformed(name: String): Boolean = |
52 try { Url(name); true } |
49 try { Url(name); true } |
53 catch { case ERROR(_) => false } |
50 catch { case ERROR(_) => false } |
54 |
51 |
161 } |
158 } |
162 |
159 |
163 def resolve(route: String): Url = |
160 def resolve(route: String): Url = |
164 if (route.isEmpty) this else new Url(uri.resolve(route)) |
161 if (route.isEmpty) this else new Url(uri.resolve(route)) |
165 |
162 |
166 def java_url: java.net.URL = uri.toURL |
163 val java_url: java.net.URL = uri.toURL |
167 def open_stream(): InputStream = java_url.openStream() |
164 def open_stream(): InputStream = java_url.openStream() |
168 def open_connection(): URLConnection = java_url.openConnection() |
165 def open_connection(): URLConnection = java_url.openConnection() |
169 } |
166 } |