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: STRF 9873 make get etc. compatible with concat return value #173

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

bc-evan-johnson
Copy link
Contributor

@bc-evan-johnson bc-evan-johnson commented Jun 20, 2022

What? Why?

#171 inadvertently broke an edge case where the concat helper is used to dynamically generate property paths.

With the original get and option helpers, this only worked with top-level properties (not nested properties) due to an implicit toString conversion here. This PR modifies those helpers to accept both top-level and nested property paths generated by concat.

Edit: During testing & review, I noticed that the old get helper would retrieve empty string keys (get({'': 0}, '') would return 0) and have made changes to match that behavior.

How was it tested?

Unit tests have been added to cover cases where concat is used to generate property paths for helpers modified in #171.


cc @bigcommerce/storefront-team

@@ -10,21 +10,21 @@ function isValidURL(val) {
}

/*
* Based on https://github.com/jonschlinkert/get-value/blob/3.0.1/index.js, but
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the intend to update this library? Looks like 2.0.6 is the current version in handlebars helpers.
Did you check if there are any breaking changes in behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating that library unfortunately wouldn't solve all our problems. We'd still need to unwrap SafeStrings, for example, as well as adding checks in getObject.

helpers/lib/common.js Outdated Show resolved Hide resolved
jairo-bc
jairo-bc previously approved these changes Jun 21, 2022
Copy link
Contributor

@jairo-bc jairo-bc left a comment

Choose a reason for hiding this comment

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

LGTM

@jairo-bc jairo-bc merged commit 75576a3 into bigcommerce:master Jun 23, 2022
@jairo-bc jairo-bc mentioned this pull request Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants