Skip to content

Commit

Permalink
Hide all inscriptions with /content/<INSCRIPTION_ID> content (ordinal…
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored and torkelrogstad committed Mar 11, 2024
1 parent 26e21b7 commit 10f0b43
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,20 +308,16 @@ impl Inscription {
}

pub(crate) fn hidden(&self) -> bool {
use regex::bytes::Regex;

lazy_static! {
static ref CONTENT: Regex = Regex::new(r"^\s*/content/[[:xdigit:]]{64}i\d+\s*$").unwrap();
}

let Some(content_type) = self.content_type() else {
return true;
};

if content_type.starts_with("text/html")
&& self
.body()
.and_then(|body| str::from_utf8(body).ok())
.map(|body| CONTENT.is_match(body))
.unwrap_or_default()
if self
.body()
.map(|body| CONTENT.is_match(body))
.unwrap_or_default()
{
return true;
}
Expand Down Expand Up @@ -813,7 +809,7 @@ mod tests {
case(
Some("text/markdown"),
Some("/content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0"),
false,
true,
);
case(
Some("text/html"),
Expand Down

0 comments on commit 10f0b43

Please sign in to comment.