Skip to content

Commit 2ec654c

Browse files
committed
fix: Removal URL encoding from MetarRetrievalService
1 parent 7d32fc3 commit 2ec654c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

app/Services/Metar/MetarRetrievalService.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MetarRetrievalService
1111
{
1212
public function retrieveMetars(Collection $airfields): Collection
1313
{
14-
$metarResponse = Http::get(config('metar.vatsim_url'), ['id' => $this->getMetarQueryString($airfields)]);
14+
$metarResponse = Http::get($this->getMetarUrl($airfields));
1515
if (!$metarResponse->ok()) {
1616
Log::error(
1717
sprintf(
@@ -35,6 +35,15 @@ public function retrieveMetars(Collection $airfields): Collection
3535
})->filter();
3636
}
3737

38+
private function getMetarUrl(Collection $airfields)
39+
{
40+
return sprintf('%s%s%s',
41+
config('metar.vatsim_url'),
42+
"?id=",
43+
$this->getMetarQueryString($airfields)
44+
);
45+
}
46+
3847
private function getMetarQueryString(Collection $airfields): string
3948
{
4049
return $airfields->concat([Carbon::now()->timestamp])->implode(',');

tests/app/Services/Metar/MetarRetrievalServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testItThrowsExceptionOnBadResponse()
3131
sprintf(
3232
'%s?id=%s',
3333
config(self::URL_CONFIG_KEY),
34-
urlencode('EGLL,EGBB,EGKR,' . $this->expectedTimestamp)
34+
'EGLL,EGBB,EGKR,' . $this->expectedTimestamp
3535
) => Http::response('', 500),
3636
]
3737
);
@@ -54,7 +54,7 @@ public function testItReturnsMetars()
5454
sprintf(
5555
'%s?id=%s',
5656
config(self::URL_CONFIG_KEY),
57-
urlencode('EGLL,EGBB,EGKR,' . $this->expectedTimestamp)
57+
'EGLL,EGBB,EGKR,' . $this->expectedTimestamp
5858
) => Http::response(
5959
implode("\n", $dataResponse)
6060
),

0 commit comments

Comments
 (0)