mirror of
https://github.com/YGGverse/titanite.git
synced 2026-03-31 09:05:31 +00:00
implement specification-compatible Url parser
This commit is contained in:
parent
1a1c0a9898
commit
3aaacdd656
1 changed files with 5 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
pub struct Header {
|
||||
pub size: usize,
|
||||
pub url: String,
|
||||
pub url: Url,
|
||||
pub mime: Option<String>,
|
||||
pub token: Option<String>,
|
||||
pub options: Option<IndexMap<String, String>>,
|
||||
|
|
@ -52,9 +52,11 @@ impl Header {
|
|||
},
|
||||
None => None,
|
||||
},
|
||||
// * Titan URL is not compatible with [STD66](https://datatracker.ietf.org/doc/html/rfc3986)
|
||||
// parse partially; see protocol specification for details
|
||||
url: match Regex::new(r"^([^;\?]+)")?.captures(header) {
|
||||
Some(c) => match c.get(1) {
|
||||
Some(v) => v.as_str().to_string(),
|
||||
Some(v) => Url::parse(v.as_str())?,
|
||||
None => bail!("URL required"),
|
||||
},
|
||||
None => bail!("URL required"),
|
||||
|
|
@ -103,3 +105,4 @@ fn test() {
|
|||
use anyhow::{bail, Result};
|
||||
use indexmap::IndexMap;
|
||||
use std::str::from_utf8;
|
||||
use url::Url;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue