| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import path from 'path';
- import { urlJoin } from '../src/utilities/urlJoin.js';
- describe( 'urlJoin', () => {
- it( 'should behave like path.join if no protocol is present', () => {
- expect(
- urlJoin( 'path', 'to', 'file.json' )
- ).toBe(
- path.normalize( 'path\\to\\file.json' )
- );
- expect(
- urlJoin( 'path//', 'to\\other\\', 'file.json' )
- ).toBe(
- path.normalize( 'path\\to\\other\\file.json' )
- );
- expect(
- urlJoin( '//path', 'to', 'file.json' )
- ).toBe(
- path.normalize( '\\\\path\\to\\file.json' )
- );
- } );
- it( 'should handle protocols correctly.', () => {
- expect(
- urlJoin( 'http://path', 'to', 'file.json' )
- ).toBe(
- path.normalize( 'http:\\\\path\\to\\file.json' )
- );
- expect(
- urlJoin( 'http://path', 'http://path2', 'to', 'file.json' )
- ).toBe(
- path.normalize( 'http:\\\\path2\\to\\file.json' )
- );
- expect(
- urlJoin( 'https://path', 'to', 'file.json' )
- ).toBe(
- path.normalize( 'https:\\\\path\\to\\file.json' )
- );
- expect(
- urlJoin( 'ftp://path', 'to', 'file.json' )
- ).toBe(
- path.normalize( 'ftp:\\\\path\\to\\file.json' )
- );
- expect(
- urlJoin( 'ftp://http://path', 'to', 'file.json' )
- ).toBe(
- path.normalize( 'ftp:\\\\http:\\path\\to\\file.json' )
- );
- } );
- } );
|