|
56 | 56 | uri_iri/2 % ?URI, ?IRI |
57 | 57 | ]). |
58 | 58 | :- autoload(library(error), [domain_error/2]). |
| 59 | +:- if(exists_source(library(socket))). |
| 60 | +:- autoload(library(socket), [gethostname/1]). |
| 61 | +:- endif. |
| 62 | + |
59 | 63 | :- use_foreign_library(foreign(uri)). |
60 | 64 |
|
61 | 65 | /** <module> Process URIs |
|
286 | 290 | !, |
287 | 291 | uri_components(URI, Components), |
288 | 292 | uri_data(scheme, Components, File), File == file, |
289 | | - ( uri_data(authority, Components, '') |
290 | | - -> true |
291 | | - ; uri_data(authority, Components, localhost) |
292 | | - ), |
| 293 | + uri_data(authority, Components, Host), |
| 294 | + my_host(Host), |
293 | 295 | uri_data(path, Components, FileNameEnc), |
294 | 296 | uri_encoded(path, FileName0, FileNameEnc), |
295 | 297 | delete_leading_slash(FileName0, FileName). |
|
304 | 306 | uri_data(path, Components, PathEnc), |
305 | 307 | uri_components(URI, Components). |
306 | 308 |
|
| 309 | +my_host('') :- !. |
| 310 | +my_host(localhost) :- !. |
| 311 | +:- if(exists_source(library(socket))). |
| 312 | +my_host(Host) :- |
| 313 | + gethostname(Host). |
| 314 | +:- endif. |
| 315 | + |
307 | 316 | %! ensure_leading_slash(+WinPath, -Path). |
308 | 317 | %! delete_leading_slash(+Path, -WinPath). |
309 | 318 | % |
|
0 commit comments