Fix form submission (#189)

This commit is contained in:
Simon Lamon 2023-01-31 14:37:10 +01:00 committed by GitHub
parent 6e25ce930d
commit c840d04789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

6
assets/links.js vendored
View file

@ -28,6 +28,8 @@ function buildRepoLink() {
} else {
window.location.assign(`/repo/${hoster}/${owner}/${repoName}${qparams}`);
}
return false;
}
function buildCrateLink() {
@ -36,10 +38,12 @@ function buildCrateLink() {
let crate = formRef.elements["crateName"].value;
let crateVer = formRef.elements["crateVersion"].value;
if (crateVer.length == 0) {
if (crateVer.length === 0) {
// default to latest version
window.location.assign(`/crate/${crate}`);
} else {
window.location.assign(`/crate/${crate}/${crateVer}`);
}
return false;
}

View file

@ -67,7 +67,7 @@ fn link_forms() -> Markup {
p class="help" id="baseUrlHelp" { "Path within the repository where the " code { "Cargo.toml" } " file is located." }
}
input type="submit" class="button is-primary" value="Check" onclick="buildRepoLink();";
input type="submit" class="button is-primary" value="Check" onclick="return buildRepoLink();";
}
}
}
@ -80,7 +80,7 @@ fn link_forms() -> Markup {
label class="label" { "Crate Name" }
div class="control" {
input class="input" type="text" id="crateName" placeholder="serde-derive" required;
input class="input" type="text" id="crateName" placeholder="serde" required;
}
}
@ -94,7 +94,7 @@ fn link_forms() -> Markup {
p class="help" { "If left blank, defaults to the latest version." }
}
input type="submit" class="button is-primary" value="Check" onclick="buildCrateLink();";
input type="submit" class="button is-primary" value="Check" onclick="return buildCrateLink();";
}
}
}