8000 Change strpos to str_contains and place it first since it is faster t… · symfony/symfony@ba77bd6 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba77bd6

Browse files
author
Konstantin Bogomolov
committed
Change strpos to str_contains and place it first since it is faster than preg_match
1 parent 4ae5fca commit ba77bd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function onSubmit(FormEvent $event)
3636
{
3737
$data = $event->getData();
3838

39-
if ($this->defaultProtocol && $data && \is_string($data) && !preg_match('~^[\w+.-]+://~', $data) && false === strpos($data, '/')) {
39+
if ($this->defaultProtocol && $data && \is_string($data) && !str_contains($data, '/') && !preg_match('~^[\w+.-]+://~', $data)) {
4040
$event->setData($this->defaultProtocol.'://'.$data);
4141
}
4242
}

0 commit comments

Comments
 (0)
0