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

Return default value if path is invalid #86

Merged
merged 6 commits into from
Sep 8, 2021

Conversation

Richienb
Copy link
Contributor

@Richienb Richienb commented Sep 8, 2021

This is the last untested part of the code (#70)

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@Richienb Richienb mentioned this pull request Sep 8, 2021
@Richienb Richienb changed the title Return default value if invalid path provided Return default value if path is invalid Sep 8, 2021
test.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Can you do a new test (with a descriptive title)

Test, not assertion.

test.js Outdated
@@ -215,5 +215,5 @@ test('prevent setting/getting `__proto__`', t => {
});

test('return default value if path is invalid', t => {
t.is(dotProp.get({}, '__proto__', '🦄'), '🦄');
t.is(dotProp.get({}, 'nonexistent', '🦄'), '🦄');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is only "invalid" if a disallowed property is passed. Testing for a legal property is already tested for.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any other non-legal value we could use that is not __proto__?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dot-prop/index.js

Lines 5 to 7 in 09adad9

'__proto__',
'prototype',
'constructor'

@sindresorhus sindresorhus merged commit d400c8d into sindresorhus:main Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants