这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions console/src/telemetryFilter.js → console/src/telemetryFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ const filterEventsBlockList = [
'RNS_REMOVE_ALL_NOTIFICATIONS',
];

const filterPayloadAllowList = [];
const DATA_PATH = '/data' as const;
const API_EXPLORER_PATH = '/api-explorer' as const;
const REMOTE_SCHEMAS_PATH = '/remote-schemas' as const;
const EVENTS_PATH = '/events' as const;

const DATA_PATH = '/data';
const API_EXPLORER_PATH = '/api-explorer';
const REMOTE_SCHEMAS_PATH = '/remote-schemas';
const EVENTS_PATH = '/events';

const dataHandler = path => {
const dataHandler = (path: string) => {
return (
DATA_PATH +
path
Expand All @@ -38,35 +36,35 @@ const apiExplorerHandler = () => {
return API_EXPLORER_PATH;
};

const remoteSchemasHandler = path => {
const remoteSchemasHandler = (path: string) => {
return (
REMOTE_SCHEMAS_PATH +
path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
);
};

const eventsHandler = path => {
const eventsHandler = (path: string) => {
return (
EVENTS_PATH +
path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
);
};

const sanitiseUrl = path => {
path = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
if (path.indexOf(DATA_PATH) === 0) {
return dataHandler(path.slice(DATA_PATH.length));
const sanitiseUrl = (path: string) => {
const newPath = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
if (newPath.indexOf(DATA_PATH) === 0) {
return dataHandler(newPath.slice(DATA_PATH.length));
}
if (path.indexOf(API_EXPLORER_PATH) === 0) {
if (newPath.indexOf(API_EXPLORER_PATH) === 0) {
return apiExplorerHandler();
}
if (path.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
return remoteSchemasHandler(path.slice(REMOTE_SCHEMAS_PATH.length));
if (newPath.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
return remoteSchemasHandler(newPath.slice(REMOTE_SCHEMAS_PATH.length));
}
if (path.indexOf(EVENTS_PATH) === 0) {
return eventsHandler(path.slice(EVENTS_PATH.length));
if (newPath.indexOf(EVENTS_PATH) === 0) {
return eventsHandler(newPath.slice(EVENTS_PATH.length));
}
return '/';
};

export { filterEventsBlockList, filterPayloadAllowList, sanitiseUrl };
export { filterEventsBlockList, sanitiseUrl };