JSPM

replace-url-protocol

1.0.10
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 62
  • Score
    100M100P100Q70010F
  • License ISC

helper for avoid node.js can't update protocol for some url

Package Exports

  • replace-url-protocol
  • replace-url-protocol/package.json
  • replace-url-protocol/src/index.js.map
  • replace-url-protocol/src/index.ts

Readme

README.md

helper for avoid node.js can't update protocol for some url

see https://github.com/nodejs/node/issues/39732

install

yarn add replace-url-protocol
yarn-tool replace set-url-protocol
yt add replace-url-protocol
import { replaceURLProtocol, replaceProtocol } from 'replace-url-protocol';

describe('node.js#39732', () =>
{

    test(`git+https:`, () =>
    {
        let u = new URL( 'git+https://url-fake-hostname/zh-TW/scripts')
        let expected = 'https:';
        replaceURLProtocol(u, expected);
        expect(u).toHaveProperty('protocol', expected);
    });

    test(`fake:`, () =>
    {
        let u = new URL( 'fake://url-fake-hostname/zh-TW/scripts')
        let expected = 'https:';
        replaceURLProtocol(u, expected);
        expect(u).toHaveProperty('protocol', expected);
    });

    test(`fake+http:`, () =>
    {
        let u = new URL( 'fake+http://url-fake-hostname/zh-TW/scripts')
        let expected = 'https:';
        replaceURLProtocol(u, expected);
        expect(u).toHaveProperty('protocol', expected);
    });

})