Skip to content

Commit

Permalink
Update LCSCProvider field for real datasheet URL
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-f committed Aug 20, 2024
1 parent a169623 commit 1964848
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Services/InfoProviderSystem/Providers/LCSCProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ private function getRealDatasheetUrl(?string $url): string
'Referer' => 'https://www.lcsc.com/product-detail/_' . $matches[2] . '.html'
],
]);
if (preg_match('/(pdfUrl): ?("[^"]+wmsc\.lcsc\.com[^"]+\.pdf")/', $response->getContent(), $matches) > 0) {
if (preg_match('/(previewPdfUrl): ?("[^"]+wmsc\.lcsc\.com[^"]+\.pdf")/', $response->getContent(), $matches) > 0) {

Check warning on line 105 in src/Services/InfoProviderSystem/Providers/LCSCProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Services/InfoProviderSystem/Providers/LCSCProvider.php#L105

Added line #L105 was not covered by tests
//HACKY: The URL string contains escaped characters like \u002F, etc. To decode it, the JSON decoding is reused
//See https://github.com/Part-DB/Part-DB-server/pull/582#issuecomment-2033125934
$jsonObj = json_decode('{"' . $matches[1] . '": ' . $matches[2] . '}');
$url = $jsonObj->pdfUrl;
$url = $jsonObj->previewPdfUrl;

Check warning on line 109 in src/Services/InfoProviderSystem/Providers/LCSCProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Services/InfoProviderSystem/Providers/LCSCProvider.php#L109

Added line #L109 was not covered by tests
}
}
return $url;
Expand Down

0 comments on commit 1964848

Please sign in to comment.