Skip to content

Commit 2d0f255

Browse files
committed
Validator Form::URL autocompletes https:// instead of http:// (BC break)
1 parent caaa2d9 commit 2d0f255

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/Forms/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public static function validateUrl(Control $control): bool
249249
if (Validators::isUrl($value)) {
250250
return true;
251251
}
252-
$value = "http://$value";
252+
$value = "https://$value";
253253
if (Validators::isUrl($value)) {
254254
$control->setValue($value);
255255
return true;

src/assets/netteForms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@
418418

419419
url: function(elem, arg, val, value) {
420420
if (!(/^[a-z\d+.-]+:/).test(val)) {
421-
val = 'http://' + val;
421+
val = 'https://' + val;
422422
}
423423
if ((/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i).test(val)) {
424424
value.value = val;

tests/Forms/Controls.TestBase.validators.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test('', function () {
7676

7777
$control->value = 'localhost';
7878
Assert::true(Validator::validateUrl($control));
79-
Assert::same('http://localhost', $control->value);
79+
Assert::same('https://localhost', $control->value);
8080

8181
$control->value = 'http://nette.org';
8282
Assert::true(Validator::validateUrl($control));

tests/Forms/Controls.TextBase.loadData.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ test('URL', function () {
151151
->addRule($form::URL);
152152

153153
$input->validate();
154-
Assert::same('http://nette.org', $input->getValue());
154+
Assert::same('https://nette.org', $input->getValue());
155155
});
156156

157157

0 commit comments

Comments
 (0)