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

Cookies can't be retrieved from store if path ends with a slash #1

Closed
lukasberns opened this issue Nov 8, 2011 · 0 comments
Closed

Comments

@lukasberns
Copy link

Hi,

I was playing with your cookies library, and I can't seem to retrieve cookies from store if they were set with a path ending with a slash. The store stores the cookies under the path as in Cookie.path, but MemoryCookieStore.findCookies looks for matching results of permutePath, which strips the trailing slash.

i.e.

jar.setCookie('hello=world; path=/some/path/', 'http://domain/some/path/file', ...)

produces something like

jar.store = { "domain": { "/some/path/": Cookie } } // notice the trailing slash

while MemoryCookieStore.findCookies("http://domain/some/path/file") looks for

jar.store["domain"]["/some/path/file"]
jar.store["domain"]["/some/path"] // no trailing slash
jar.store["domain"]["/some"]
jar.store["domain"]["/"]

instead of

jar.store["domain"]["/some/path/"] // has trailing slash

So it returns an empty array.

I think CookieJar.setCookie or some other method should run Cookie.path = permutePath(Cookie.path).shift() on the cookie if it has a non-empty path set.

Anyway, nice module :)
Cheers,
Lukas

@ghost ghost assigned stash Nov 8, 2011
stash added a commit that referenced this issue Nov 8, 2011
Exposed by the test case for GH-1.  Commit also adds a shortcut for
empty path or domain.
@stash stash closed this as completed in d78d3a3 Nov 8, 2011
wjhsf pushed a commit that referenced this issue Feb 8, 2024
add LICENSE and license headers
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

No branches or pull requests

2 participants