Skip to content

Commit e2e9759

Browse files
committed
fix style for large tests
1 parent 8f8c247 commit e2e9759

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/simple.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ async fn download(Path(file_name): Path<FileName>, db: Data<DB>) -> Result<impl
106106
#[routes]
107107
#[get("raw/{id}.{ext}")]
108108
#[get("raw/{id}")]
109+
#[get("{id}.{ext}", guard = "no_browser")]
110+
#[get("{id}", guard = "no_browser")]
109111
async fn raw(
110112
Path(FileName { id, ext }): Path<FileName>,
111113
database: Data<DB>,
@@ -136,6 +138,22 @@ async fn raw(
136138
}
137139
}
138140

141+
fn no_browser(it: &GuardContext) -> bool {
142+
const MOZILLA: &[u8] = b"Mozilla";
143+
!it.head()
144+
.headers
145+
.get(header::USER_AGENT)
146+
.map_or(false, |it| {
147+
let it = it.as_bytes();
148+
for i in 0..it.len() - MOZILLA.len() {
149+
if &it[i..(i + MOZILLA.len())] == MOZILLA {
150+
return true;
151+
}
152+
}
153+
false
154+
})
155+
}
156+
139157
#[routes]
140158
#[get("{id}.{ext}")]
141159
#[get("{id}")]
@@ -183,7 +201,7 @@ async fn get_ext(
183201
}
184202
.to_response()
185203
}
186-
_ if file.len() < 10_000 => {
204+
_ if file.len() < 50_000 => {
187205
if let Ok(file) =
188206
String::from_utf8(file.to_vec().await.map_err(ErrorInternalServerError)?)
189207
{
@@ -494,6 +512,6 @@ async fn post_form(
494512
file.ok_or_else(|| UploadError::NoData)?,
495513
cookies,
496514
extension,
497-
&config
515+
&config,
498516
))
499517
}

templates/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ bottom-border {
226226

227227
main {
228228
flex-grow: 1;
229-
max-height: 600px;
229+
/* Figure out something better */
230+
max-height: max(600px, calc(100vh - 200px));
230231
gap: inherit;
231232
display: flex;
232233
flex-direction: column;

0 commit comments

Comments
 (0)