Skip to content

Commit

Permalink
fix(tiktok): remove duplicate leading slash in url path, fix #3884 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dvikan authored Jan 10, 2024
1 parent 491cb50 commit 0eb4f6b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bridges/TikTokBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ public function collectData()
foreach ($videos as $video) {
$item = [];

// Handle link "untracking"
$linkParts = parse_url($video->find('a', 0)->href);
$link = $linkParts['scheme'] . '://' . $linkParts['host'] . '/' . $linkParts['path'];
// Omit query string (remove tracking parameters)
$a = $video->find('a', 0);
$href = $a->href;
$parsedUrl = parse_url($href);
$url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . '/' . ltrim($parsedUrl['path'], '/');

$image = $video->find('video', 0)->poster;
$views = $video->find('div[data-e2e=common-Video-Count]', 0)->plaintext;

$enclosures = [$image];

$item['uri'] = $link;
$item['uri'] = $url;
$item['title'] = 'Video';
$item['author'] = '@' . $author;
$item['enclosures'] = $enclosures;
$item['content'] = <<<EOD
<a href="{$link}"><img src="{$image}"/></a>
<a href="{$url}"><img src="{$image}"/></a>
<p>{$views} views<p><br/>
EOD;

Expand Down

0 comments on commit 0eb4f6b

Please sign in to comment.