This repository was archived by the owner on Oct 29, 2025. It is now read-only.
Added cookie name extraction#66
Merged
Merged
Conversation
| function extractCookieNames(cookieHeader) { | ||
| var result; | ||
| if(cookieHeader){ | ||
| var cookies = cookieHeader.split(';'); |
| if(cookieHeader){ | ||
| var cookies = cookieHeader.split(';'); | ||
| var cookieNames = new Array (cookies.length); | ||
| for (var i = 0; i < cookies.length ; i++){ |
There was a problem hiding this comment.
a single javascript line can do all this at once:
Suggested change
| for (var i = 0; i < cookies.length ; i++){ | |
| const cookieNames = cookies.map(cookie => cookie.split('=')[0].trim()); |
| module_version: config.MODULE_VERSION, | ||
| cookie_origin: pxCtx.cookieOrigin | ||
| cookie_origin: pxCtx.cookieOrigin, | ||
| risk_cookie_names: pxCtx.risk_cookie_names |
There was a problem hiding this comment.
should be pxCtx.riskCookieNames
There was a problem hiding this comment.
how did work when you tested it?
Contributor
Author
There was a problem hiding this comment.
It worked because I tested in with the correct name. Don't knwo how the name switch has happened
| it('should extract cookie names from the cookie header', (done) => { | ||
| var cookieHeader = '_px3=px3Cookie;tempCookie=CookieTemp; _px7=NotARealCookie'; | ||
| var formattedHeaders = pxutil.extractCookieNames(cookieHeader); | ||
| (Object.prototype.toString.call(formattedHeaders)).should.be.exactly('[object Array]'); |
There was a problem hiding this comment.
why not formattedHeaders.toString()? this will actually pretty print the array instead of the general [object Array]
Contributor
Author
There was a problem hiding this comment.
Because I want to know the type, not the value
There was a problem hiding this comment.
In that case
Suggested change
| (Object.prototype.toString.call(formattedHeaders)).should.be.exactly('[object Array]'); | |
| Array.isArray(formattedHeaders).should.be.true() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.