Skip to content

Cannot clone a URL in Node >= 10 #109

Description

@iambalaam

The following code will run in node8, but break in node10 and node12.

const clone = require('clone');
const { URL } = require('url');
const url = new URL('https://example.com');

const url2 = clone(url);

It gives the following stacktrace

TypeError: Cannot set property 'flags' of undefined
    at URL.onParseComplete (internal/url.js:224:13)
    at URL.set [as href] (internal/url.js:443:7)
    at _clone (.../code/node-cache-fix/node_modules/clone/clone.js:162:16)
    at clone (.../code/node-cache-fix/node_modules/clone/clone.js:202:10)
    at Object.<anonymous> (.../code/node-cache-fix/clone-bug.js:5:14)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions