mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-26 18:36:14 -04:00
Clean comments (#6420)
* Add script to trigger test on utils * Add new function to remove the comments from the settings file. It reduces the size of the payload when we save on the admin page `.../admin/settings` * Add font-family: monospace; to the settings
This commit is contained in:
parent
2e2fb13268
commit
13e160cbe4
6 changed files with 53 additions and 6 deletions
|
@ -1,5 +1,14 @@
|
|||
const minify = (json: string)=>{
|
||||
export const cleanComments = (json: string|undefined)=>{
|
||||
if (json !== undefined){
|
||||
json = json.replace(/\/\*.*?\*\//g, ""); // remove single line comments
|
||||
json = json.replace(/ *\/\*.*(.|\n)*?\*\//g, ""); // remove multi line comments
|
||||
json = json.replace(/[ \t]+$/gm, ""); // trim trailing spaces
|
||||
json = json.replace(/^(\n)/gm, ""); // remove empty lines
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
export const minify = (json: string)=>{
|
||||
let tokenizer = /"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g,
|
||||
in_string = false,
|
||||
in_multiline_comment = false,
|
||||
|
@ -49,9 +58,6 @@ const minify = (json: string)=>{
|
|||
return new_str.join("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export const isJSONClean = (data: string) => {
|
||||
let cleanSettings = minify(data);
|
||||
// this is a bit naive. In theory some key/value might contain the sequences ',]' or ',}'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue