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

Should handle copying of headers when they're of type Headers #90

Open
megoth opened this issue Nov 12, 2018 · 1 comment
Open

Should handle copying of headers when they're of type Headers #90

megoth opened this issue Nov 12, 2018 · 1 comment
Assignees
Labels

Comments

@megoth
Copy link

megoth commented Nov 12, 2018

options.headers might be a simple object or iniated with the Headers API. Copying an object of type Headers using spread syntax will not copy the key-values stored within the object.

As auth.fetch is a wrapper for the Fetch API, we might expect people to use the Headers API to initiate headers that are passed through the options parameter.

I have created a branch that aims to fix this, but struggle a bit with the tests, so need some help.

@RubenVerborgh
Copy link
Contributor

Can we just fix it in webid-oidc.js by replacing

...(options && options.headers ? options.headers : {}),

with

...toObject(options && options.headers),

where

function toObject(headers = {}) {
  if (typeof headers.forEach !== 'function')
    return headers
  const newHeaders = {}
  headers.forEach((value, key) => {
    newHeaders[key] = value
  })
  return newHeaders
}

Then we can simply test in solid-auth-client.spec.js as a variant of https://github.com/solid/solid-auth-client/blob/v2.2.11/src/__test__/solid-auth-client.spec.js#L527.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants