Skip to content

Commit cd42c25

Browse files
committed
FIX: exists? on not existing URL must return FALSE instead of error
fixes: #14
1 parent f3dfa7b commit cd42c25

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/mezz/base-files.r

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ exists?: func [
2020
{Determines if a file or URL exists.}
2121
target [file! url!]
2222
][
23-
not none? query/mode target 'type
23+
either error? try [
24+
target: query/mode target 'type
25+
][ false ][ not none? target ]
2426
]
2527

2628
size?: func [

src/tests/units/port-test.r3

+8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ if "true" <> get-env "CONTINUOUS_INTEGRATION" [
116116
--assert block? v: query/mode system/ports/input m
117117
--assert 4 = length? v
118118
===end-group===
119+
120+
===start-group=== "HTTP"
121+
--test-- "exists? url"
122+
;@@ https://github.com/Oldes/Rebol3/issues/14
123+
--assert exists? http://httpbin.org/
124+
--assert not exists? http://httpbin.org/not-exists
125+
126+
===end-group===
119127
]
120128

121129
~~~end-file~~~

0 commit comments

Comments
 (0)