Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix percent char decoding #2124

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion packages/core/src/util/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const resolveData = (instance: any, dataPath: string): any => {
const dataPathSegments = dataPath.split('.');

return dataPathSegments
.map(segment => decodeURIComponent(segment))
.reduce((curInstance, decodedSegment) => {
if (!curInstance || !curInstance.hasOwnProperty(decodedSegment)) {
return undefined;
Expand Down
6 changes: 0 additions & 6 deletions packages/core/test/util/path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ test('resolve instance with keywords', t => {
const result = Resolve.data(instance, toDataPath('#/properties/properties'));
t.is(result, 123);
});
test('resolve instance with encoded', t => {
const instance = { 'foo/bar': 123 };
const fooBar = encodeURIComponent('foo/bar');
const result = Resolve.data(instance, toDataPath(`#/properties/${fooBar}`));
t.is(result, 123);
});
test('resolve nested instance', t => {
const instance = { foo: { bar: 123 } };
const result = Resolve.data(
Expand Down
10 changes: 9 additions & 1 deletion packages/core/test/util/resolvers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { resolveSchema } from '../../src/util/resolvers';
import { resolveData, resolveSchema } from '../../src/util/resolvers';
import test from 'ava';

test('resolveSchema - resolves schema with any ', t => {
Expand Down Expand Up @@ -155,3 +155,11 @@ test('resolveSchema - resolves schema with encoded characters', t => {
t.deepEqual(resolveSchema(schema, '#/properties/foo ~1 ~0 bar', schema), {type: 'integer'});
t.is(resolveSchema(schema, '#/properties/foo / bar', schema), undefined);
});


test('resolveData - resolves data with % characters', t => {
const data = {
'foo%': '123'
};
t.deepEqual(resolveData(data, 'foo%'), '123');
});