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 'ignore' for keys containing key delimiter #209

Merged
merged 3 commits into from Jul 19, 2021

Conversation

TzeWey
Copy link
Contributor

@TzeWey TzeWey commented Jul 19, 2021

This PR fixes the issue reported by @acidoxee in #132 (comment) just before the issue was closed.

This commit attempts to overcome the limitation by allowing the user to escape the dot character used as a delimiter.

The method used is to split the key by the dot delimiter ignoring any escaped dots, followed by replacing all occurrences of the escaped dots. Alternatively, it is possible to use a negative lookbehind regex for the split, but might not be supported on all browsers.

Thanks!

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1044509237

  • 0 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 1038015337: 0.0%
Covered Lines: 286
Relevant Lines: 286

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 19, 2021

Pull Request Test Coverage Report for Build 1045049814

  • 21 of 21 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 1038015337: 0.0%
Covered Lines: 306
Relevant Lines: 306

💛 - Coveralls

lib/utils.js Outdated
*/
function deleteLogProperty (log, property) {
const props = property.split('.')
const props = property.match(/([^\\.]|\\\.)+/g).map((e) => e.split('\\.').join('.'))
Copy link
Contributor

Choose a reason for hiding this comment

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

how expensive is this operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://jsbench.me/tqkrafwdkf/1

I just performed some benchmarks, this implementation is ~81% slower compared to just a split.

There might be quite a hit on performance with this change, however, this can be improved if we split the key using a loop. Benchmark shows that it is ~36% slower compared to just a split.

Will be pushing the improved version shortly for review.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 289de2b into pinojs:master Jul 19, 2021
@TzeWey TzeWey deleted the fix-ignore-escape-2 branch July 19, 2021 14:37
@acidoxee
Copy link

acidoxee commented Aug 3, 2021

Thanks very much for this PR!

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.

None yet

5 participants