Skip to content
Snippets Groups Projects
Select Git revision
  • e95bd0ba3dcf73767517b2eed3412ae5635fef2a
  • main default protected
  • next
  • renovate/main-redis-5.x
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • fix/36615-branch-reuse-bug
  • refactor/pin-new-value
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • fix/32307-global-extends-merging
  • fix/32307-global-extends-repositories
  • gh-readonly-queue/next/pr-35009-046ebf7cb84ab859f7fefceb5fa53a54ce9736f8
  • gh-readonly-queue/next/pr-35009-9d5e583b7d7251148ab0d11ee8dd38149618d162
  • 41.17.2
  • 41.17.1
  • 41.17.0
  • 41.16.3
  • 41.16.2
  • 41.16.1
  • 41.16.0
  • 41.15.0
  • 41.14.0
  • 41.13.1
  • 41.13.0
  • 41.12.1
  • 41.12.0
  • 41.11.1
  • 41.11.0
  • 41.10.1
  • 41.10.0
  • 41.9.0
  • 41.8.0
  • 41.7.2
41 results

error-messages.ts

Blame
    • Rhys Arkins's avatar
      e95bd0ba
      feat(host-rules): add support for disabling hosts (#6715) · e95bd0ba
      Rhys Arkins authored
      * feat(host-rules): support disabling hosts
      
      Adds “enabled” to the list of recognized configuration options for hostRules. A host or domain can be disabled by setting `”enabled”: false` within the host rule. Also added presets :disabledHost() and :disableDomain().
      
      * docs
      
      * tests
      
      * Update configuration-options.md
      
      * fixes
      feat(host-rules): add support for disabling hosts (#6715)
      Rhys Arkins authored
      * feat(host-rules): support disabling hosts
      
      Adds “enabled” to the list of recognized configuration options for hostRules. A host or domain can be disabled by setting `”enabled”: false` within the host rule. Also added presets :disabledHost() and :disableDomain().
      
      * docs
      
      * tests
      
      * Update configuration-options.md
      
      * fixes
    url.spec.ts 5.97 KiB
    import {
      createURLFromHostOrURL,
      ensurePathPrefix,
      ensureTrailingSlash,
      getQueryString,
      joinUrlParts,
      parseLinkHeader,
      parseUrl,
      resolveBaseUrl,
      trimTrailingSlash,
      validateUrl,
    } from './url';
    
    describe('util/url', () => {
      test.each([
        ['http://foo.io', '', 'http://foo.io'],
        ['http://foo.io/', '', 'http://foo.io'],
        ['http://foo.io', '/', 'http://foo.io/'],
        ['http://foo.io/', '/', 'http://foo.io/'],
    
        ['http://foo.io', '/aaa', 'http://foo.io/aaa'],
        ['http://foo.io', 'aaa', 'http://foo.io/aaa'],
        ['http://foo.io/', '/aaa', 'http://foo.io/aaa'],
        ['http://foo.io/', 'aaa', 'http://foo.io/aaa'],
        ['http://foo.io', '/aaa/', 'http://foo.io/aaa/'],
        ['http://foo.io', 'aaa/', 'http://foo.io/aaa/'],
        ['http://foo.io/', '/aaa/', 'http://foo.io/aaa/'],
        ['http://foo.io/', 'aaa/', 'http://foo.io/aaa/'],
    
        ['http://foo.io/aaa', '/bbb', 'http://foo.io/aaa/bbb'],
        ['http://foo.io/aaa', 'bbb', 'http://foo.io/aaa/bbb'],
        ['http://foo.io/aaa/', '/bbb', 'http://foo.io/aaa/bbb'],
        ['http://foo.io/aaa/', 'bbb', 'http://foo.io/aaa/bbb'],
    
        ['http://foo.io/aaa', '/bbb/', 'http://foo.io/aaa/bbb/'],
        ['http://foo.io/aaa', 'bbb/', 'http://foo.io/aaa/bbb/'],
        ['http://foo.io/aaa/', '/bbb/', 'http://foo.io/aaa/bbb/'],
        ['http://foo.io/aaa/', 'bbb/', 'http://foo.io/aaa/bbb/'],
    
        ['http://foo.io', 'http://bar.io/bbb', 'http://bar.io/bbb'],
        ['http://foo.io/', 'http://bar.io/bbb', 'http://bar.io/bbb'],
        ['http://foo.io/aaa', 'http://bar.io/bbb', 'http://bar.io/bbb'],
        ['http://foo.io/aaa/', 'http://bar.io/bbb', 'http://bar.io/bbb'],
    
        ['http://foo.io', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
        ['http://foo.io/', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
        ['http://foo.io/aaa', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
        ['http://foo.io/aaa/', 'http://bar.io/bbb/', 'http://bar.io/bbb/'],
    
        ['http://foo.io', 'aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
        ['http://foo.io', '/aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
        ['http://foo.io/', 'aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
        ['http://foo.io/', '/aaa?bbb=z', 'http://foo.io/aaa?bbb=z'],
    
        ['http://foo.io', 'aaa/?bbb=z', 'http://foo.io/aaa?bbb=z'],
      ])('%s + %s => %s', (baseUrl, x, result) => {
        expect(resolveBaseUrl(baseUrl, x)).toBe(result);
      });
    
      it('getQueryString', () => {
        expect(getQueryString({ a: 1, b: [1, 2] })).toBe('a=1&b=1&b=2');
      });
    
      it('validates URLs', () => {
        expect(validateUrl()).toBeFalse();
        expect(validateUrl(null as never)).toBeFalse();
        expect(validateUrl('foo')).toBeFalse();
        expect(validateUrl('ssh://github.com')).toBeFalse();
        expect(validateUrl('http://github.com')).toBeTrue();
        expect(validateUrl('https://github.com')).toBeTrue();
        expect(validateUrl('https://github.com', false)).toBeTrue();
      });
    
      it('parses URL', () => {
        expect(parseUrl(null as never)).toBeNull();
        expect(parseUrl(undefined as never)).toBeNull();
    
        const url = parseUrl('https://github.com/renovatebot/renovate');
        expect(url?.protocol).toBe('https:');
        expect(url?.host).toBe('github.com');
        expect(url?.pathname).toBe('/renovatebot/renovate');
      });
    
      it('trimTrailingSlash', () => {
        expect(trimTrailingSlash('foo')).toBe('foo');
        expect(trimTrailingSlash('/foo/bar')).toBe('/foo/bar');
        expect(trimTrailingSlash('foo/')).toBe('foo');
        expect(trimTrailingSlash('foo//////')).toBe('foo');
      });
    
      it('ensureTrailingSlash', () => {
        expect(ensureTrailingSlash('')).toBe('/');
        expect(ensureTrailingSlash('/')).toBe('/');
      });
    
      it('ensures path prefix', () => {
        expect(ensurePathPrefix('https://index.docker.io', '/v2')).toBe(
          'https://index.docker.io/v2/'
        );
        expect(ensurePathPrefix('https://index.docker.io/v2', '/v2')).toBe(
          'https://index.docker.io/v2'
        );
        expect(
          ensurePathPrefix('https://index.docker.io/v2/something', '/v2')
        ).toBe('https://index.docker.io/v2/something');
        expect(ensurePathPrefix('https://index.docker.io:443', '/v2')).toBe(
          'https://index.docker.io/v2/'
        );
        expect(
          ensurePathPrefix('https://index.docker.io/something?with=query', '/v2')
        ).toBe('https://index.docker.io/v2/something?with=query');
      });
    
      it('joinUrlParts', () => {
        const registryUrl = 'https://some.test';
        expect(joinUrlParts(registryUrl, 'foo')).toBe(`${registryUrl}/foo`);
        expect(joinUrlParts(registryUrl, '/?foo')).toBe(`${registryUrl}?foo`);
        expect(joinUrlParts(registryUrl, '/foo/bar/')).toBe(
          `${registryUrl}/foo/bar/`
        );
        expect(joinUrlParts(`${registryUrl}/foo/`, '/foo/bar')).toBe(
          `${registryUrl}/foo/foo/bar`
        );
        expect(joinUrlParts(`${registryUrl}/api/`, '/foo/bar')).toBe(
          `${registryUrl}/api/foo/bar`
        );
        expect(joinUrlParts('foo//////')).toBe('foo/');
      });
    
      it('createURLFromHostOrURL', () => {
        expect(createURLFromHostOrURL('https://some.test')).toEqual(
          new URL('https://some.test/')
        );
        expect(createURLFromHostOrURL('some.test')).toEqual(
          new URL('https://some.test/')
        );
      });
    
      it('parseLinkHeader', () => {
        expect(parseLinkHeader(null)).toBeNull();
        expect(parseLinkHeader(' '.repeat(2001))).toBeNull();
        expect(
          parseLinkHeader(
            '<https://api.github.com/user/9287/repos?page=3&per_page=100>; rel="next",' +
              '<https://api.github.com/user/9287/repos?page=1&per_page=100>; rel="prev"; pet="cat", ' +
              '<https://api.github.com/user/9287/repos?page=5&per_page=100>; rel="last"'
          )
        ).toStrictEqual({
          next: {
            page: '3',
            per_page: '100',
            rel: 'next',
            url: 'https://api.github.com/user/9287/repos?page=3&per_page=100',
          },
          prev: {
            page: '1',
            per_page: '100',
            rel: 'prev',
            pet: 'cat',
            url: 'https://api.github.com/user/9287/repos?page=1&per_page=100',
          },
          last: {
            page: '5',
            per_page: '100',
            rel: 'last',
            url: 'https://api.github.com/user/9287/repos?page=5&per_page=100',
          },
        });
      });
    });