Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Robustness] stringify: avoid relying on a global undefined - #427

#427
Merged
ljharb merged 1 commit into
ljharb:masterljharb/qs:masterfrom
Connormiha:simplify-checking-undefindedConnormiha/qs:simplify-checking-undefindedCopy head branch name to clipboard
Dec 27, 2021
Merged

[Robustness] stringify: avoid relying on a global undefined#427
ljharb merged 1 commit into
ljharb:masterljharb/qs:masterfrom
Connormiha:simplify-checking-undefindedConnormiha/qs:simplify-checking-undefindedCopy head branch name to clipboard

Conversation

@Connormiha

@Connormiha Connormiha commented Dec 27, 2021

Copy link
Copy Markdown
Contributor

I just removed needless(for these cases) typeof for checking for undefined

update: Added checking for typeof in parser.

@ljharb ljharb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

These are not needless at all. undefined can be redefined in every scope except the global scope in ES5, and in ES3 - which this package supports - it can be modified in the global scope otherwise.

@Connormiha

Copy link
Copy Markdown
Contributor Author

@ljharb

These are not needless at all. undefined can be redefined in every scope except the global scope in ES5, and in ES3 - which this package supports - it can be modified in the global scope otherwise.

Yes, but there are many places with same check. For example https://github.com/ljharb/qs/blob/master/lib/stringify.js#L155 or https://github.com/ljharb/qs/blob/master/lib/stringify.js#L195

@ljharb

ljharb commented Dec 27, 2021

Copy link
Copy Markdown
Owner

In that case, those should be changed to use typeof instead :-) want to update the PR to do that?

@Connormiha

Copy link
Copy Markdown
Contributor Author

@ljharb typeof or void 0? Which one is preferable?

@Connormiha
Connormiha force-pushed the simplify-checking-undefinded branch from 852cab8 to de140f3 Compare December 27, 2021 20:42
@Connormiha Connormiha changed the title [Refactor] simplify checking for undefined [Refactor] Add compatibility for ES3 Dec 27, 2021
@Connormiha

Copy link
Copy Markdown
Contributor Author

@ljharb updated.

@ljharb

ljharb commented Dec 27, 2021

Copy link
Copy Markdown
Owner

Definitely the typeof, because it has minimal runtime weight.

@ljharb ljharb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Almost there.

Comment thread lib/stringify.js Outdated
Comment thread lib/stringify.js Outdated
@ljharb ljharb changed the title [Refactor] Add compatibility for ES3 [Robustness] stringify: avoid relying on a global undefined Dec 27, 2021

@ljharb ljharb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks!

@ljharb
ljharb force-pushed the simplify-checking-undefinded branch from 5c1223e to 0a1d3e8 Compare December 27, 2021 21:51
@codecov

codecov Bot commented Dec 27, 2021

Copy link
Copy Markdown

Codecov Report

Merging #427 (0a1d3e8) into master (408ff95) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #427   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files           8        8           
  Lines        1408     1408           
  Branches      172      172           
=======================================
  Hits         1406     1406           
  Misses          2        2           
Impacted Files Coverage Δ
lib/stringify.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 408ff95...0a1d3e8. Read the comment docs.

@ljharb
ljharb merged commit 0a1d3e8 into ljharb:master Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.