Skip to content

Commit

Permalink
NTR: fix tracking code (#846)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalij Mik <[email protected]>
  • Loading branch information
BlackScorp and Vitalij Mik committed Sep 26, 2024
1 parent 64ff8c5 commit d527e37
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Service/TrackingInfoStructFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private function createInfoStruct(string $trackingCarrier, string $trackingCode,
]);

// determine if the provided tracking code is actually a tracking URL
if (empty($trackingUrl) === true || $this->urlParsingService->isUrl($trackingCode)) {
if (empty($trackingUrl) === true && $this->urlParsingService->isUrl($trackingCode)) {
$this->logger->debug('Tracking code is a URL, parsing tracking code from URL.', [
'trackingCode' => $trackingCode,
'trackingUrl' => $trackingUrl
Expand Down
2 changes: 1 addition & 1 deletion src/Service/UrlParsingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function parseTrackingCodeFromUrl(string $value): array
$urlQuery = parse_url($value, PHP_URL_FRAGMENT);
}
if ($urlQuery === null) {
return ['', $value];
return [$value,''];
}
$urlQuery = (string)$urlQuery;
$urlWithoutQuery = str_replace($urlQuery, '', $value);
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPUnit/Service/UrlParsingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function testParseTrackingCodeNotFound(string $input, array $expected)
public function notFoundProvider(): array
{
return [
['https://www.example.com/product', ['', 'https://www.example.com/product']],
['https://www.example.com/code/product', ['', 'https://www.example.com/code/product']],
['https://www.example.com/product', ['https://www.example.com/product','']],
['https://www.example.com/code/product', ['https://www.example.com/code/product','']],
];
}

Expand Down

0 comments on commit d527e37

Please sign in to comment.