Skip to content

Commit 0f92a69

Browse files
authored
Rewrite LCSC datasheet URL (#795)
1 parent 8faa325 commit 0f92a69

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Services/InfoProviderSystem/Providers/LCSCProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ private function queryDetail(string $id): PartDetailDTO
9797
private function getRealDatasheetUrl(?string $url): string
9898
{
9999
if ($url !== null && trim($url) !== '' && preg_match("/^https:\/\/(datasheet\.lcsc\.com|www\.lcsc\.com\/datasheet)\/.*(C\d+)\.pdf$/", $url, $matches) > 0) {
100+
if (preg_match("/^https:\/\/datasheet\.lcsc\.com\/lcsc\/(.*\.pdf)$/", $url, $rewriteMatches) > 0) {
101+
$url = 'https://www.lcsc.com/datasheet/lcsc_datasheet_' . $rewriteMatches[1];
102+
}
100103
$response = $this->lcscClient->request('GET', $url, [
101104
'headers' => [
102105
'Referer' => 'https://www.lcsc.com/product-detail/_' . $matches[2] . '.html'

0 commit comments

Comments
 (0)