Skip to content

Commit

Permalink
minor #26566 [BrowserKit] Improves CookieJar::get (dunglas)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[BrowserKit] Improves CookieJar::get

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      |no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

* change a call to `substr` + `strlen` to a single `strpos`

Commits
-------

5799314 [BrowserKit] Improves CookieJar::get
  • Loading branch information
fabpot committed Mar 16, 2018
2 parents d246326 + 5799314 commit 1390529
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/CookieJar.php
Expand Up @@ -47,13 +47,13 @@ public function get($name, $path = '/', $domain = null)
foreach ($this->cookieJar as $cookieDomain => $pathCookies) {
if ($cookieDomain) {
$cookieDomain = '.'.ltrim($cookieDomain, '.');
if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) {
if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) {
continue;
}
}

foreach ($pathCookies as $cookiePath => $namedCookies) {
if ($cookiePath != substr($path, 0, strlen($cookiePath))) {
if (0 !== strpos($path, $cookiePath)) {
continue;
}
if (isset($namedCookies[$name])) {
Expand Down

0 comments on commit 1390529

Please sign in to comment.