Skip to content

Commit

Permalink
Use std LazyLock instead of lazy_regex.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Jul 31, 2024
1 parent 890878f commit 2625d54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on

* Improved item (image) sizing css. I hope it works in safari.
* Updated to `diesel` 2.1.0, `diesel-async` 0.3.2, and `ructe` 0.17.0.
* Uses std LazyLock (require rust 1.80) instead of `lazy_regex`.
* Some more known kinds of places.


Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "rphotos"
version = "0.12.3-PRE"
authors = ["Rasmus Kaj <[email protected]>"]
edition = "2021"
msrv = "1.80"

build = "src/build.rs"

Expand All @@ -21,12 +22,12 @@ flate2 = "1.0.14"
futures-lite = "1.12.0"
image = "0.24.0"
kamadak-exif = "0.5.0"
lazy-regex = "2.2.2"
libc = "0.2.68"
medallion = "2.3.1"
mime = "0.3.0"
r2d2-memcache = "0.6"
rand = "0.8"
regex = "1.10.5"
reqwest = { version = "0.11.0", features = ["json"] }
serde = { version = "1.0.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
7 changes: 5 additions & 2 deletions src/server/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use crate::schema::users::dsl as u;
use crate::templates;
use diesel::prelude::*;
use diesel_async::{AsyncPgConnection, RunQueryDsl};
use lazy_regex::regex_is_match;
use regex::Regex;
use serde::Deserialize;
use std::sync::LazyLock;
use tracing::info;
use warp::filters::BoxedFilter;
use warp::http::header;
Expand Down Expand Up @@ -91,8 +92,10 @@ impl LoginForm {
}

fn sanitize_next(next: Option<&str>) -> Option<&str> {
static RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"^/([a-z0-9._-]+/?)*$").unwrap());
if let Some(next) = next {
if regex_is_match!(r"^/([a-z0-9._-]+/?)*$", next) {
if RE.is_match(next) {
return Some(next);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/views_by_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ sql_function! {
}

mod filter {
use diesel::sql_types::{Nullable, Timestamp};
use diesel::sql_function;
use diesel::sql_types::{Nullable, Timestamp};

sql_function! {
fn year_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
Expand Down

0 comments on commit 2625d54

Please sign in to comment.