Skip to content

Commit

Permalink
Merge pull request #48 from ismaxim/hotfixes
Browse files Browse the repository at this point in the history
refactor: replace webmozart assertion to native solution
  • Loading branch information
maximgrynykha authored Mar 27, 2021
2 parents b26935a + 22bdc9f commit 1475d79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/Urling/Core/Misc/Tools/Misc/SwissKnife.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ public static function truncateExtraSlashes(string $resource): string
return str_replace(':/', '://', trim((string) preg_replace('/\/+/', '/', $resource), '/'));
}

/**
* @param string|null $string
* @param string|null $_string
*
* @return bool
*/
public static function isSameStrings(?string $string, ?string $_string): bool
{
return !strcmp((string) $string, (string) $_string);
}

/**
* @param string $context
* @param string $separator
Expand Down
4 changes: 2 additions & 2 deletions src/Urling/Core/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function isSameOrigin(string $url, string $origin = null, bool $verify_pr
$url_protocol = UrlParser::getPartValueFromUrl($url, "protocol");
$origin_protocol = UrlParser::getPartValueFromUrl($origin, "protocol");

if (!Assert::same((string) $url_protocol, (string) $origin_protocol)) {
if (!Tools::isSameStrings((string) $url_protocol, (string) $origin_protocol)) {
return false;
}
}
Expand All @@ -88,6 +88,6 @@ public function isSameOrigin(string $url, string $origin = null, bool $verify_pr
return false;
}

return Assert::same((string) $url_hostname, (string) $origin_hostname);
return Tools::isSameStrings((string) $url_hostname, (string) $origin_hostname);
}
}

0 comments on commit 1475d79

Please sign in to comment.