JSPM

replace-url-protocol

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

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

Package Exports

  • replace-url-protocol

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (replace-url-protocol) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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);
    });

})