mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-05 15:02:08 +08:00
Strip sensitive information contained in URLs from frontend API calls
This commit is contained in:
@@ -53,3 +53,12 @@ export function jsonArrayTransform(data, transform) {
|
||||
export function jsonArrayFilter(data, filter) {
|
||||
return jsonArrayTransform(data, (items) => items.filter(filter));
|
||||
}
|
||||
|
||||
export function sanitizeErrorURL(errorURL) {
|
||||
// Dont display sensitive params on frontend
|
||||
const url = new URL(errorURL);
|
||||
["apikey", "api_key", "token", "t"].forEach(key => {
|
||||
if (url.searchParams.has(key)) url.searchParams.set(key, "***")
|
||||
});
|
||||
return url.toString();
|
||||
}
|
||||
Reference in New Issue
Block a user