5.0-dev1
- rewrote and/or optimized all service modules - rewrote matching and processing modules to optimize readability and performance - added support for reddit gifs - fixed various issues with twitter error explanations - code optimizations and enhancements (such as finally getting rid of ==, prettier and more readable formatting, etc) - added branch information - all functions in currentCommit submodule run only once and cache received data - added a test script. only twitter and soundcloud are 100% covered and tested atm, will add tests (and probably fixes) for the rest of services in next commits - changed some localization strings for russian - added more clarity to rate limit message - moved services folder into processing folder
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
import { execSync } from "child_process";
|
||||
|
||||
let commit, commitInfo, branch;
|
||||
|
||||
export function shortCommit() {
|
||||
return execSync('git rev-parse --short HEAD').toString().trim()
|
||||
if (commit) return commit;
|
||||
let c = execSync('git rev-parse --short HEAD').toString().trim();
|
||||
commit = c;
|
||||
return c
|
||||
}
|
||||
export function getCommitInfo() {
|
||||
let d = execSync(`git show -s --format='%s;;;%B'`).toString().trim().replace(/[\r\n]/gm, '\n').split(';;;')
|
||||
d[1] = d[1].replace(d[0], '').trim().toString().replace(/[\r\n]/gm, '<br>')
|
||||
if (commitInfo) return commitInfo;
|
||||
let d = execSync(`git show -s --format='%s;;;%B'`).toString().trim().replace(/[\r\n]/gm, '\n').split(';;;');
|
||||
d[1] = d[1].replace(d[0], '').trim().toString().replace(/[\r\n]/gm, '<br>');
|
||||
commitInfo = d;
|
||||
return d
|
||||
}
|
||||
export function getCurrentBranch() {
|
||||
if (branch) return branch;
|
||||
let b = execSync('git branch --show-current').toString().trim();
|
||||
branch = b;
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import loc from "../../localization/manager.js";
|
||||
export function errorUnsupported(lang) {
|
||||
return loc(lang, 'ErrorUnsupported');
|
||||
}
|
||||
export function genericError(lang, host) {
|
||||
export function brokenLink(lang, host) {
|
||||
return loc(lang, 'ErrorBrokenLink', host);
|
||||
}
|
||||
export function genericError(lang, host) {
|
||||
return loc(lang, 'ErrorBadFetch', host);
|
||||
}
|
||||
|
||||
@@ -103,10 +103,9 @@ export function checkJSONPost(obj) {
|
||||
}
|
||||
try {
|
||||
let objKeys = Object.keys(obj);
|
||||
if (!(objKeys.length < 8 && obj.url)) {
|
||||
return false
|
||||
}
|
||||
if (!(objKeys.length <= 8 && obj.url)) return false;
|
||||
let defKeys = Object.keys(def);
|
||||
|
||||
for (let i in objKeys) {
|
||||
if (String(objKeys[i]) !== "url" && defKeys.includes(objKeys[i])) {
|
||||
if (apiVar.booleanOnly.includes(objKeys[i])) {
|
||||
@@ -116,12 +115,14 @@ export function checkJSONPost(obj) {
|
||||
}
|
||||
}
|
||||
}
|
||||
obj["url"] = decodeURIComponent(String(obj["url"]))
|
||||
|
||||
obj["url"] = decodeURIComponent(String(obj["url"]));
|
||||
let hostname = obj["url"].replace("https://", "").replace(' ', '').split('&')[0].split("/")[0].split("."),
|
||||
host = hostname[hostname.length - 2]
|
||||
def["url"] = encodeURIComponent(cleanURL(obj["url"], host))
|
||||
host = hostname[hostname.length - 2];
|
||||
def["url"] = encodeURIComponent(cleanURL(obj["url"], host));
|
||||
|
||||
return def
|
||||
} catch (e) {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user