Remove the Regex dependency.
This isn't really necessary if we're checking against a list of valid versions.
This commit is contained in:
parent
9ef1bf37ef
commit
4f285142d8
|
@ -2,15 +2,6 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
|
@ -147,7 +138,6 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
|||
name = "opml"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
"strong-xml",
|
||||
"thiserror",
|
||||
|
@ -209,29 +199,12 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
|
|
|
@ -15,7 +15,6 @@ keywords = ["xml", "opml"]
|
|||
path = "source/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
regex = "1.5.4"
|
||||
strong-xml = "0.6.3"
|
||||
thiserror = "1.0.29"
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
//! To create an OPML document from scratch, use [`OPML::default()`] or the good
|
||||
//! old `OPML { /* ... */ }` syntax.
|
||||
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strong_xml::{XmlRead, XmlWrite};
|
||||
use thiserror::Error;
|
||||
|
@ -105,16 +104,11 @@ impl OPML {
|
|||
pub fn from_str(xml: &str) -> Result<Self, Error> {
|
||||
let opml = <OPML as XmlRead>::from_str(xml)?;
|
||||
|
||||
let version = &opml.version;
|
||||
|
||||
// SPEC: The version attribute is a version string, of the form, x.y, where
|
||||
// x and y are both numeric strings.
|
||||
let valid_version_regex = Regex::new(r"^\d+\.\d+$").unwrap();
|
||||
let valid_versions = vec!["1.0", "1.1", "2.0"];
|
||||
|
||||
if !valid_version_regex.is_match(version)
|
||||
|| !valid_versions.contains(&version.as_str())
|
||||
{
|
||||
if !valid_versions.contains(&opml.version.as_str()) {
|
||||
return Err(Error::UnsupportedVersion(opml.version));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue