mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-01 18:18:31 +00:00
Add HREF validity functions with documentation
This commit is contained in:
parent
4e99105225
commit
84fd30f357
1 changed files with 34 additions and 0 deletions
|
@ -1352,6 +1352,40 @@ function bytesToHumanReadable(bytes, dp=1) {
|
||||||
return (bytes / Math.pow(1024, i)).toFixed(dp) * 1 + ' ' + ['b', 'kb', 'mb', 'gb', 'tb'][i];
|
return (bytes / Math.pow(1024, i)).toFixed(dp) * 1 + ' ' + ['b', 'kb', 'mb', 'gb', 'tb'][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removed invalid HREF characters for a collection HREF.
|
||||||
|
*
|
||||||
|
* @param a A valid Input element or an onchange Event of an Input element.
|
||||||
|
*/
|
||||||
|
function cleanHREFinput(a) {
|
||||||
|
let href_form = a;
|
||||||
|
if (a.target) {
|
||||||
|
href_form = a.target;
|
||||||
|
}
|
||||||
|
let currentTxtVal = href_form.value.trim().toLowerCase();
|
||||||
|
//Clean the HREF to remove non lowercase letters and dashes
|
||||||
|
currentTxtVal = currentTxtVal.replace(/(?![0-9a-z\-\_])./g, '');
|
||||||
|
href_form.value = currentTxtVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a proposed HREF for a collection has a valid format and syntax.
|
||||||
|
*
|
||||||
|
* @param href String of the porposed HREF.
|
||||||
|
*
|
||||||
|
* @return Boolean results if the HREF is valid.
|
||||||
|
*/
|
||||||
|
function isValidHREF(href) {
|
||||||
|
if (href.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (href.indexOf("/") != -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
// Hide startup loading message
|
// Hide startup loading message
|
||||||
document.getElementById("loadingscene").classList.add("hidden");
|
document.getElementById("loadingscene").classList.add("hidden");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue