changed startsWith to contains

This commit is contained in:
Franklin 2022-09-20 00:45:35 -04:00
parent 7c8abe9d56
commit a0beba17a0
3 changed files with 4 additions and 4 deletions

2
Cargo.lock generated
View File

@ -183,7 +183,7 @@ dependencies = [
[[package]] [[package]]
name = "actix-web-utils" name = "actix-web-utils"
version = "0.2.18" version = "0.2.19"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"log", "log",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-web-utils" name = "actix-web-utils"
version = "0.2.18" version = "0.2.19"
edition = "2021" edition = "2021"
authors = ["Franklin E. Blanco"] authors = ["Franklin E. Blanco"]
description = "Just some useful addons for actix web." description = "Just some useful addons for actix web."

View File

@ -40,14 +40,14 @@ impl FromStr for Error {
type Err = Error; type Err = Error;
fn from_str(string: &str) -> Result<Self, Self::Err> { fn from_str(string: &str) -> Result<Self, Self::Err> {
let error_name_option = string.get(14..24); let error_name_option = string.get(13..25);
let error_name_whole = match error_name_option { let error_name_whole = match error_name_option {
Some(error_name_whole) => error_name_whole, Some(error_name_whole) => error_name_whole,
None => return Err(Error::Unspecified), None => return Err(Error::Unspecified),
}; };
if error_name_whole.starts_with("Unspecified") { if error_name_whole.starts_with("Unspecified") {
return Err(Self::Unspecified) return Err(Self::Unspecified)
} else if error_name_whole.starts_with("UnexpectedStatusCode") { } else if error_name_whole.contains("UnexpectedStatusCode") {
let expected_str_index = string.find("Expected: ").unwrap() + 10; let expected_str_index = string.find("Expected: ").unwrap() + 10;
let actual_str_index = string.find("Actual: ").unwrap() + 8; let actual_str_index = string.find("Actual: ").unwrap() + 8;
let expected_status_code = string.get(expected_str_index..expected_str_index+3).unwrap(); let expected_status_code = string.get(expected_str_index..expected_str_index+3).unwrap();