Skip to content

Commit 9024c83

Browse files
committed
Refactor base_url extraction logic
1 parent a5e6e12 commit 9024c83

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@ impl UrlPattern {
2929
} else if value.is_none() {
3030
(None, options)
3131
} else {
32-
(
33-
Some(
34-
value
35-
.extract::<String>()?
36-
.parse::<url::Url>()
37-
.map_err(::urlpattern::Error::Url)
38-
.map_err(Error)?,
39-
),
40-
options,
41-
)
32+
(base_url, options)
4233
}
4334
}
4435
None => (None, options),
4536
};
4637

38+
let base_url = if let Some(base_url) = base_url {
39+
Some(
40+
base_url
41+
.extract::<String>()?
42+
.parse::<url::Url>()
43+
.map_err(::urlpattern::Error::Url)
44+
.map_err(Error)?,
45+
)
46+
} else {
47+
None
48+
};
49+
4750
let options = if let Some(options) = options {
4851
::urlpattern::UrlPatternOptions {
4952
ignore_case: options

0 commit comments

Comments
 (0)