Skip to content

Commit

Permalink
Hide JSON and .btc (ordinals#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Nov 24, 2023
1 parent 03bcba8 commit fe8f055
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ impl Inscription {
return false;
};

if content_type != "text/plain" && content_type != "text/plain;charset=utf-8" {
if content_type.starts_with("application/json") {
return true;
}

if !content_type.starts_with("text/plain") {
return false;
}

Expand All @@ -338,6 +342,10 @@ impl Inscription {
return true;
}

if trimmed.ends_with(".btc") {
return true;
}

false
}
}
Expand Down Expand Up @@ -808,12 +816,15 @@ mod tests {
case(Some("foo"), Some("{}"), false);
case(Some("text/plain"), None, false);
case(Some("text/plain"), Some("foo{}bar"), false);
case(Some("text/plain"), Some("foo.btc"), true);

case(Some("text/plain"), Some("foo.bitmap"), true);
case(Some("text/plain"), Some("gib bc1"), true);
case(Some("text/plain"), Some("{}"), true);
case(Some("text/plain"), Some(" {} "), true);
case(Some("text/plain;charset=utf-8"), Some("foo.bitmap"), true);
case(Some("text/plain;charset=cn-big5"), Some("foo.bitmap"), true);
case(Some("application/json"), Some("foo"), true);

assert!(!Inscription {
content_type: Some("text/plain".as_bytes().into()),
Expand Down

0 comments on commit fe8f055

Please sign in to comment.