Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocesarato committed Oct 22, 2021
1 parent 90e5bdc commit 917103d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ protected function getMarkdownChanges(array $changes): string
*/
protected function getMarkdownLink(string $text, string $url): string
{
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url); // Remove double slashes

return !$this->config->isDisableLinks() ? "[{$text}]({$url})" : $text;
}

Expand Down Expand Up @@ -591,7 +593,7 @@ public function getCommitUrl(string $hash): string
$format = $this->config->getCommitUrlFormat();
$url = $this->getCompiledString($format, ['hash' => $hash]);

return self::cleanUrl("{$protocol}://{$url}");
return "{$protocol}://{$url}";
}

/**
Expand All @@ -607,7 +609,7 @@ public function getCompareUrl(string $previousTag, string $currentTag): string
$format = $this->config->getCompareUrlFormat();
$url = $this->getCompiledString($format, ['previousTag' => $previousTag, 'currentTag' => $currentTag]);

return self::cleanUrl("{$protocol}://{$url}");
return "{$protocol}://{$url}";
}

/**
Expand All @@ -623,7 +625,7 @@ public function getIssueUrl(string $id): string
$format = $this->config->getIssueUrlFormat();
$url = $this->getCompiledString($format, ['id' => $id]);

return self::cleanUrl("{$protocol}://{$url}");
return "{$protocol}://{$url}";
}

/**
Expand All @@ -639,7 +641,7 @@ public function getUserUrl(string $user): string
$format = $this->config->getUserUrlFormat();
$url = $this->getCompiledString($format, ['user' => $user]);

return self::cleanUrl("{$protocol}://{$url}");
return "{$protocol}://{$url}";
}

/**
Expand All @@ -651,12 +653,4 @@ public function getReleaseCommitMessage(string $tag): string

return $this->getCompiledString($format, ['currentTag' => $tag]);
}

/**
* Clean url format.
*/
private static function cleanUrl(string $url): string
{
return preg_replace('/([^:])(\/{2,})/', '$1/', $url);
}
}

0 comments on commit 917103d

Please sign in to comment.