fix: escape uri encoded symbols (#1697)

This commit is contained in:
Dmitriy Dekhanov
2020-11-19 11:55:09 -08:00
committed by GitHub
parent c8d38b6258
commit f8f8fbcac4
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -40,6 +40,14 @@ test('Escape regexp special characters', (t) => {
);
});
test('Escape regexp special characters in url-encoded environment variable', (t) => {
const env = {SOME_PASSWORD: 'secret password p$^{.+}\\w[a-z]o.*rd)('};
t.is(
hideSensitive(env)(`https://user:${encodeURI(env.SOME_PASSWORD)}@host.com`),
`https://user:${SECRET_REPLACEMENT}@host.com`
);
});
test('Accept "undefined" input', (t) => {
t.is(hideSensitive({})(), undefined);
});