Skip to content

Commit 8268572

Browse files
committed
fix suffix when displaying X-Forwaded-For
1 parent 76905de commit 8268572

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

crates/common/src/config/signer.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ impl Display for ReverseProxyHeaderSetup {
9292
write!(f, "\"{header} (unique)\"")
9393
}
9494
ReverseProxyHeaderSetup::Rightmost { header, trusted_count } => {
95-
let suffix = match trusted_count.get() % 10 {
96-
1 => "st",
97-
2 => "nd",
98-
3 => "rd",
95+
let n = trusted_count.get();
96+
let suffix = match (n % 100, n % 10) {
97+
(11..=13, _) => "th",
98+
(_, 1) => "st",
99+
(_, 2) => "nd",
100+
(_, 3) => "rd",
99101
_ => "th",
100102
};
101103
write!(f, "\"{header} ({trusted_count}{suffix} from the right)\"")

0 commit comments

Comments
 (0)