Git Product home page Git Product logo

headers-polyfill's People

Contributors

abienz avatar brophdawg11 avatar dependabot[bot] avatar enet4 avatar felipeplets avatar jacob-ebey avatar joshkel avatar kettanaito avatar mattcosta7 avatar mister-hope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

headers-polyfill's Issues

Cypress: Unexpected token on nullish coalescence operator

Hello, I'm getting this error with @cypress/webpack-preprocessor due to this change

  • cypress version 10.4.0
Error: Webpack Compilation Error
../node_modules/msw/node_modules/headers-polyfill/lib/index.js 105:64
Module parse failed: Unexpected token (105:64)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   }
|   get(name) {
>     return this[NORMALIZED_HEADERS][normalizeHeaderName(name)] ?? null;
|   }
|   set(name, value) {
 @ ../node_modules/msw/lib/node/index.mjs 269:0-51 276:22-37 411:0-43 414:22-29 488:0-71 491:0-51 494:18-33 570:26-42 642:0-55 696:19-27 720:0-55 723:0-55 755:19-27
 @ ../node_modules/@s-ui/mock/lib/server.js
 @ ../node_modules/@s-ui/mock/lib/index.js
 @ ../mocks/index.js
 @ ./support/index.js
    at handle (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/@cypress/webpack-preprocessor/dist/index.js:180:23)
    at finalCallback (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:257:39)
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:306:14
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:304:22
    at Compiler.emitRecords (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:499:39)
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:298:10
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:485:14
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:482:27
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/neo-async/async.js:2818:7
    at done (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/neo-async/async.js:3522:9)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:464:33
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/travis/.cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqCallback.oncomplete (node:fs:192:23)

Splits "user-agent" when encountered comma

Current behavior

Given called headersToObject with the following header:

user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.0 Safari/537.36 

It splits this header by encountered , (comma), resulting into two headers:

Screen Shot 2020-05-12 at 09 00 12

Expected behavior

I suppose certain headers can have commas, and can never have multiple values. I think this library should respect that.

License?

I don't see any license declared for this, and no license file. The only reference I see is in the package.json, but this doesn't satisfy the license requirements. Can one be decided on and added to the repository?

Nullish coalescing operator (??) causing webpack build to fail

Recent commit "feat: implements "getSetCookie" method on Headers" (cff8faf)

changed line 74 of src/headers.ts (https://github.com/mswjs/headers-polyfill/blob/main/src/Headers.ts#L73)
from:

get(name: string): string | null {
  return this[NORMALIZED_HEADERS][normalizeHeaderName(name)] || null
}

to

get(name: string): string | null {
  return this[NORMALIZED_HEADERS][normalizeHeaderName(name)] ?? null
}

(now using the Nullish coalescing operator (??))

This is now causing webpack to throw a build error.

 ERROR  Failed to compile with 1 error9:19:13 pm

 error  in ./node_modules/headers-polyfill/lib/index.mjs

Module parse failed: Unexpected token (71:64)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   }
|   get(name) {
>     return this[NORMALIZED_HEADERS][normalizeHeaderName(name)] ?? null;
|   }
|   set(name, value) {

 @ ./node_modules/msw/lib/index.js 147:30-57 304:31-58 542:31-58 549:31-58 574:31-58 927:31-58 1002:31-58 1005:31-58 1610:31-58
 @ ./src/mocks/browser.js
 @ ./src/main.js
 @ multi ./src/main.js

 ERROR  Build failed with errors.

I've created a repo to make it easy to reproduce the issue.

I've also created a shell script (show-error.sh) to quickly show the error and what happens when you revert the change from to the ?? operator.

Move custom Headers methods to transformer functions

To improve specification-compliance, we must not set any custom methods on the Headers instance. This includes:

  • all()
  • raw()

Instead, remove those methods and implement them as transformers:

import { Headers, getAllHeaders, getRawHeaders } from 'headers-polyfill'

const headers = new Headers({})
getAllHeaders(headers)
getRawHeaders(headers)

Header value contains an extra trailing empty space

GitHub

Current behavior

When appending a header via headers.set(name, value) the value sometimes contains an empty trailing space:

{
  "x-powered-by": "msw ",
  "content-type": "application/json ",
  "x-header": "yes"
}

See the values of the x-powered-by and content-type headers.

Expected behavior

Header values do not contain extra leading/trailing spaces.

Fails to create a Headers instance given another Headers instance as init

const h = new Headers({ accept: '*/*' })
const h2 = new Headers(h)

Current behavior

{
  _headers: { _headers: '[object Object], _names: '[object Object]' },
  _names: Map { accept => 'accept' }
}

Expected behavior

{
  _headers: { accept: '*/*' },
  _names: Map { accept => 'accept' }
}

Motivation

The standard Headers instance can be used as the init to another Headers instance.

response3.headers.all is not a function

I'm using [email protected]

The fresh installation installs [email protected] through @mswjs/interceptors.

I stopped to work for graphql. We receive now this error when calling mocked graqpql endpoint

Received: [[GraphQLError: request to http://localhost:9990/api/test failed, reason: response3.headers.all is not a function]]

Using [email protected] resolution works without problem

  "resolutions": {
    "headers-polyfill": "3.2.5"
  }

Missing "./lib" export in "headers-polyfill" package

I'm using vite with mswjs. After I bump versions of non-major dependencies, the following error is thrown caused by headers-polyfill. Currently, downgrading to v3.0.10 can fix it.

vite v3.1.1 building for production...
transforming...
✓ 25 modules transformed.
[commonjs--resolver] Missing "./lib" export in "headers-polyfill" package
file: /home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected]/node_modules/msw/lib/index.js
error during build:
Error: Missing "./lib" export in "headers-polyfill" package
    at bail (file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-a713b95d.js:33701:8)
    at resolve (file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-a713b95d.js:33778:10)
    at resolveExports (file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-a713b95d.js:34835:12)
    at resolveDeepImport (file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-a713b95d.js:34853:31)
    at tryNodeResolve (file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-a713b95d.js:3[45](https://github.com/kingyue737/vitify-admin/actions/runs/3059919545/jobs/4937844820#step:8:46)70:20)
    at Object.resolveId (file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-a713b95d.js:34343:28)
    at file:///home/runner/work/vitify-admin/vitify-admin/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:22710:40
 ELIFECYCLE  Command failed with exit code 1.
Error: The process '/home/runner/setup-pnpm/node_modules/.bin/pnpm' failed with exit code 1

Package subpath './lib' is not defined by "exports"

I just ran npm update, which updated headers-polyfill to the just released 3.1.0, which modifies the exports in package.json. This is the error I get:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib' is not defined by "exports" in /myapp/node_modules/headers-polyfill/package.json
    at new NodeError (node:internal/errors:387:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:464:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:748:3)
    at resolveExports (node:internal/modules/cjs/loader:493:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:533:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/myapp/node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest/NodeClientRequest.js:89:13) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Unable to set multiple "set-cookie" headers

According to MDN, setting multiple cookies in an HTTP response should be done by using multiple "Set-Cookie" headers.

To send multiple cookies, multiple Set-Cookie headers should be sent in the same response.

As far as I know, this is not possible with the headers-polyfill.

> const  h = new Headers();
> h.set('set-cookie', 'foo=bar');
> h.set('set-cookie', 'bar=baz');
> h.raw()
-> { 'set-cookie': 'bar=baz' }

There should be a way for setting multiple set-cookie entries. Comma-separated value (set-cookie: foo=bar, bar=baz) is deprecated and not implemented by modern browsers.

3.2.0 does not handle Set-Cookie as expected

Here is a reproduction that sets two cookies and outputs them, once via getSetCookie, once via forEach:

r.mjs
import {Headers} from "headers-polyfill";
// import {Headers} from "undici";

const h = new Headers();
h.append(
    "set-cookie",
    "a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT",
);
h.append(
    "Set-Cookie",
    "b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT",
);

const cookies = [];
h.forEach((value, key) => {
    cookies.push(value);
});
console.log("cookies via forEach:", cookies);

console.log("cookeis via getSetCookie", h.getSetCookie())
$ node r.mjs
cookies via forEach: [
  'a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT, b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT'
]
cookeis via getSetCookie [
  'a=a; Expires=Wed',
  '21 Oct 2015 07:28:00 GMT',
  'b=b; Expires=Wed',
  '21 Oct 2015 07:28:00 GMT'
]

I would expect forEach and getSetCookie to produce the same result, an array with two entries, one for each cookie.

With undici, we get the expected result:

$ node r.mjs
cookies via forEach: [
  'a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT',
  'b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT'
]
cookeis via getSetCookie [
  'a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT',
  'b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT'
]

Add "stringToHeaders"

Useful when dealing with XMLHttpRequest.getAllResponseHeaders.

Input:

date: Fri, 08 Dec 2017 21:04:30 GMT\r\n
content-encoding: gzip\r\n
x-content-type-options: nosniff\r\n
server: meinheld/0.6.1\r\n
x-frame-options: DENY\r\n
content-type: text/html; charset=utf-8\r\n
connection: keep-alive\r\n
strict-transport-security: max-age=63072000\r\n
vary: Cookie, Accept-Encoding\r\n
content-length: 6502\r\n
x-xss-protection: 1; mode=block\r\n

Output: Record<string, string | string[]>

There's no lib folder which is called from /esm/package.json

I'm getting this error in a project with MSW since yesterday

Failed to compile.

./node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest/NodeClientRequest.js
Module not found: Package path ./lib is not exported from package /node_modules/headers-polyfill (see exports field in /node_modules/headers-polyfill/package.json)

The issue is there's no lib folder and /esm/package.json couldn't get such dependencies

MSW is installed in my project since April working flawless, but since your last update (yesterday) stopped working

Losing headers when using Undici in latest Node 18.x

Node.js's update to Undici 5.26.3 caused its Headers class to be called _Headers:

https://github.com/nodejs/node/pull/50153/files#diff-f516ab824a7722da938a4c7c851520d39731ddeb4f7198dff4e932c5d4f8fdf7

As a result, passing a native Undici Headers object to headers-polyfill (which happens when MSW intercepts a native Node.js fetch request with headers) loses the headers' contents.

To reproduce, run the following script in Node.js 18.16.1 (where it outputs the expected headers) and Node 18.18.2 (where it does not).

const hp = require('headers-polyfill');

console.log(hp.headersToString(new hp.Headers(new Headers({'Content-Type': 'application/json'}))));

Package subpath './lib' is not defined by "exports"

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/headers-polyfill/package.json b/node_modules/headers-polyfill/package.json
index 83849d7..4eb24a3 100644
--- a/node_modules/headers-polyfill/package.json
+++ b/node_modules/headers-polyfill/package.json
@@ -10,7 +10,8 @@
       "types": "./lib/index.d.ts",
       "require": "./lib/index.js",
       "default": "./lib/index.mjs"
-    }
+    },
+    "./lib": "./lib/index.js"
   },
   "repository": "https://github.com/mswjs/headers-polyfill",
   "author": "Artem Zakharchenko",

This issue body was partially generated by patch-package.

Package subpath './lib' is not defined by "exports"

I'm getting the following error with a package that uses headers-polyfill version 3.1.2

Error: Package subpath './lib' is not defined by "exports" in /Users/marklyck/colony/colony-frontend/node_modules/.pnpm/@[email protected]/node_modules/headers-polyfill/package.json
 ❯ Object.<anonymous> node_modules/.pnpm/@[email protected]/node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest/NodeClientRequest.js:100:13
 ❯ Object.<anonymous> node_modules/.pnpm/@[email protected]/node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest/http.get.js:25:27
 ❯ Object.<anonymous> node_modules/.pnpm/@[email protected]/node_modules/@mswjs/interceptors/lib/interceptors/ClientRequest/index.js:54:18
 ❯ Object.<anonymous> node_modules/.pnpm/[email protected][email protected]/node_modules/msw/lib/node/index.js:63:28
 
 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
  "code": "ERR_PACKAGE_PATH_NOT_EXPORTED",
}


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Is this an issue with msw using the package wrong? Or is it a problem with this package?

I have not updated msw but it looks like this was working in headers-polyfill version 3.0.10

Webpack compilation error after update

Hello,

I believe that after update to v3.1.0 there're some troubles with compiling. Failed to compile output looks like this:

../node_modules/msw/lib/index.js
Module not found: Package path ./lib is not exported from package /app/node_modules/headers-polyfill (see exports field in /app/node_modules/headers-polyfill/package.json)
Import trace for requested module:
./src/mocks/browser.js
./src/mocks/index.js
./src/pages/executions-tmv1/index.page.tsx
> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Uploading artifacts for failed job

Didn't have much time to deep dive, but maybe you're aware?

The module does not support ESM correctly

Reproduce Steps

  1. Install the package:
$ yarn add headers-polyfill
  1. Put the following code into index.mjs:
import { Headers } from 'headers-polyfill';
  1. Execute index.mjs:
$ node index.mjs

Get the following error:

file:///Users/chentsulin/oss/test-headers-polyfill/index.mjs:1
import { Headers } from 'headers-polyfill'
         ^^^^^^^
SyntaxError: Named export 'Headers' not found. The requested module 'headers-polyfill' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'headers-polyfill';
const { Headers } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Version 3.1.0 => Error: Package subpath './lib' is not defined by "exports"

With the newest version 3.1.0, we are facing an error within our integration pipeline.

We are using msw for testing, which has header-polyfills as dependency.

With header-polyfills version 3.0.10 everything was fine, with 3.1.0 we are getting this error:

Error: Package subpath './lib' is not defined by "exports" in /foo/node_modules/headers-polyfill/package.json

Our setup uses TypeScript and a Lerna Monorepo with Node 16.x

Can't import the named export 'splitCookiesString'

Hi There, Facing the below issue , while building the application. (npm run build)
Can't import the named export 'splitCookiesString' from non EcmaScript module (only default export is available)
Can you please check once

import {splitCookiesString} from "set-cookie-parser";

Invalid Headers.js syntax ?

Following the recent 3.0.9, I'm having this issue when trying to start storybook (that does have msw/msw-storybook-addon :

ERROR in /project/node_modules/headers-polyfill/lib/Headers.js 9:25
Module parse failed: Unexpected token (9:25)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| class HeadersPolyfill {
|     // Normalized header {"name":"a, b"} storage.
>     [NORMALIZED_HEADERS] = {};
|     // Keeps the mapping between the raw header name
|     // and the normalized header name to ease the lookup.

Found someone else on S/O with the same issue as well.

Reverting to 3.0.4 via yarn resolutions worked for me.

FWIW I'm using babel-loader 8.1.0 in case that makes a difference, as the loader was mentioned.

Also, I'm seeing that Headers.js for 3.0.4 looks like minified js, whereas this looks much more like plain (pre-transpiler) javascript.

I do see the change in #33 that switches targets from ES5 to esnext... would that have this effect?

Please let me know if you need any other information about my project.
node v16.16

Error: Package path ./lib is not exported from package

I just installed the headers-polyfill package (v3.1.0) and I'm getting the following error when I run the project (it's a CRA project):

ERROR in ./node_modules/msw/lib/index.js 564:17-48
Module not found: Error: Package path ./lib is not exported from package C:<path to app>\test-app\node_modules\headers-polyfill (see exports field in C:<path to app>\test-app\node_modules\headers-polyfill\package.json)

It seems the following code was added in package.json in the 3.1.0 release and this seems to be the root cause:

"exports": {
  ".": {
    "types": "./lib/index.d.ts",
    "require": "./lib/index.js",
    "default": "./lib/esm/index.js"
  }
},

Keep private properties under symbols

private is really just a TypeScript sugar. Our internal properties right now are enumerable, leaking their presence and values to the end consumer:

private headers: Record<string, string> = {}

private names: Map<string, string> = new Map()

Proposal

Keep headers and names under symbols. Symbols are not enumerable by default, and can be accessed only by direct symbol reference. This is a great way of keeping internal properties.

"flattenHeadersObject" joins multi-value headers but semicolon, not comma

Current behavior

const h = new Headers()
h.append('x', '1')
h.append('x', '2')

flattenHeadersObject(headersToObject(h))
// {"x":"1;2"}

Expected behavior

Multiple values of the same header are joined by a comma, not a semicolon.

  • Source
  • This is also how Fetch API Headers returns multi-value headers.
flattenHeadersObject(headersToObject(h))
// {"x":"1,2"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.