Skip to content

Add support for 'json-edit', 'json-edit-xhr-response' and 'json-edit-fetch-response' #566

@AdamWr

Description

@AdamWr

https://github.com/gorhill/ublock/wiki/Resources-Library#json-edit

If I'm not wrong, to do that we can just add aliases for these scriptlets in json-prune, json-prune-xhr-response and json-prune-fetch-response.
And change resolveJsonSyntaxMode to automatically detect JSONPath mode when propsToRemove starts with dot:

export function resolveJsonSyntaxMode(
expression: string | undefined,
mode: string | undefined,
): ResolvedJsonSyntax {
const LEGACY_MODE = 'legacy';
const JSONPATH_MODE = 'jsonpath';
const JSONPATH_GUARD = '[?';
const JSONPATH_ROOT_GUARD = '$';
const normalizedMode = typeof mode === 'string' ? mode.trim().toLowerCase() : '';
if (normalizedMode === LEGACY_MODE || normalizedMode === JSONPATH_MODE) {
return {
mode: normalizedMode as JsonPathSyntaxMode,
};
}
const normalizedExpression = typeof expression === 'string' ? expression.trim() : '';
if (normalizedExpression.startsWith(JSONPATH_ROOT_GUARD) || normalizedExpression.startsWith(JSONPATH_GUARD)) {
return {
mode: JSONPATH_MODE,
};
}
return {
mode: LEGACY_MODE,
};
}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions