29 lines
1.3 KiB
PHP
29 lines
1.3 KiB
PHP
<?php
|
|
|
|
it('accepts hostnames containing underscores', function () {
|
|
// Regression: PHP's FILTER_VALIDATE_URL rejects underscores in the host,
|
|
// which blocked valid service domains (e.g. Docker service naming) from
|
|
// being saved and getting Let's Encrypt certificates. See issue #10597.
|
|
expect(isValidDomainUrl('https://myapp_service.example.com'))->toBeTrue();
|
|
expect(isValidDomainUrl('http://my_app.example.com'))->toBeTrue();
|
|
expect(isValidDomainUrl('https://a_b_c.example.com/path'))->toBeTrue();
|
|
});
|
|
|
|
it('accepts ordinary domains and URLs', function () {
|
|
expect(isValidDomainUrl('https://example.com'))->toBeTrue();
|
|
expect(isValidDomainUrl('http://sub.example.com:8080/path?q=1'))->toBeTrue();
|
|
expect(isValidDomainUrl('https://example.com/a_b'))->toBeTrue();
|
|
});
|
|
|
|
it('rejects strings that are not valid URLs', function () {
|
|
expect(isValidDomainUrl('not a url'))->toBeFalse();
|
|
expect(isValidDomainUrl('example.com'))->toBeFalse();
|
|
expect(isValidDomainUrl('ht_tp://example.com'))->toBeFalse();
|
|
expect(isValidDomainUrl(''))->toBeFalse();
|
|
});
|
|
|
|
it('rejects URLs that do not use HTTP or HTTPS schemes', function () {
|
|
expect(isValidDomainUrl('ftp://example.com'))->toBeFalse();
|
|
expect(isValidDomainUrl('javascript://example.com'))->toBeFalse();
|
|
expect(isValidDomainUrl('data://example.com'))->toBeFalse();
|
|
});
|