Skip to content

Commit

Permalink
fix: 🐛 fix format! {}
Browse files Browse the repository at this point in the history
  • Loading branch information
holmofy committed Oct 20, 2024
1 parent 359631b commit 9746c74
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "reqwest-scraper-macros"]

[package]
name = "reqwest-scraper"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
description = "Web scraping integration with reqwest"
license = "MIT"
Expand All @@ -25,7 +25,7 @@ libxml = { version = "0.3", optional = true }
scraper = { version = "0.20", optional = true }
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
reqwest-scraper-macros = { version = "0.5.0", path = "./reqwest-scraper-macros", optional = true }
reqwest-scraper-macros = { version = "0.5.3", path = "./reqwest-scraper-macros", optional = true }
thiserror = "1.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion reqwest-scraper-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "reqwest-scraper-macros"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
description = "Web scraping integration with reqwest"
license = "MIT"
Expand Down
7 changes: 6 additions & 1 deletion reqwest-scraper-macros/src/include_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ impl<'f> StrEnum<'f> {
let matched = caps.get(0).unwrap();
let name = caps.name("ident").unwrap().as_str();
let ty = caps.name("ty").map(|ty| ty.as_str());
fmt.push_str(&string[last_match..matched.start()]);
// format!转义,要保留原始{},得{{}}
fmt.push_str(
&string[last_match..matched.start()]
.replace("{", "{{")
.replace("}", "}}"),
);
fmt.push_str(&format!(r"{{{name}}}"));
args.push(FormatArg { name, ty });
last_match = matched.end();
Expand Down

0 comments on commit 9746c74

Please sign in to comment.