File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,14 @@ impl Drop for Url {
136
136
}
137
137
138
138
impl Url {
139
+ /// Parses the input with an optional base
140
+ ///
141
+ /// ```
142
+ /// use ada_url::Url;
143
+ /// let out = Url::parse("https://ada-url.github.io/ada", None)
144
+ /// .expect("This is a valid URL. Should have parsed it.");
145
+ /// assert_eq!(out.protocol(), "https:");
146
+ /// ```
139
147
pub fn parse ( input : & str , base : Option < & str > ) -> Result < Url , Error > {
140
148
unsafe {
141
149
let url_aggregator = match base {
@@ -159,6 +167,13 @@ impl Url {
159
167
}
160
168
}
161
169
170
+ /// Returns whether or not the URL can be parsed or not.
171
+ ///
172
+ /// ```
173
+ /// use ada_url::Url;
174
+ /// assert!(Url::can_parse("https://ada-url.github.io/ada", None));
175
+ /// assert!(Url::can_parse("/pathname", Some("https://ada-url.github.io/ada")));
176
+ /// ```
162
177
pub fn can_parse ( input : & str , base : Option < & str > ) -> bool {
163
178
unsafe {
164
179
if let Some ( base) = base {
You can’t perform that action at this time.
0 commit comments