Skip to content

Commit

Permalink
When linking to ports, strip any suffixes such as @py27 or :configure
Browse files Browse the repository at this point in the history
This allows the link to work, but the text will retain the original value.
  • Loading branch information
dlangille committed Dec 4, 2017
1 parent 8a5487c commit ef10971
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions include/freshports.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ function PortsFreezeStatus($ColSpan=1) {
}


function freshports_strip_port_suffix($PortName) {
# a dependency might look like:
# devel/py-setuptools@py27
# devel/py-setuptools:configure
#
# but we can't link to that, so we remove the suffix

$PortName = strtok($PortName, "@:");

return $PortName;
}

function freshports_link_to_port($CategoryName, $PortName, $BranchName = BRANCH_HEAD) {

$HTML = '';
Expand All @@ -162,7 +174,7 @@ function freshports_link_to_port($CategoryName, $PortName, $BranchName = BRANCH_

// create link to port, perhaps on a branch
//
$HTML .= '<a href="/' . $CategoryName . '/' . $PortName . '/';
$HTML .= '<a href="/' . $CategoryName . '/' . freshports_strip_port_suffix($PortName) . '/';
if ($BranchName != BRANCH_HEAD) {
$HTML .= '?branch=' . htmlentities($BranchName);
}
Expand All @@ -178,7 +190,7 @@ function freshports_link_to_port_single($CategoryName, $PortName, $BranchName =
// link to both category and port

$HTML = '';
$HTML .= '<a href="/' . $CategoryName . '/' . $PortName . '/';
$HTML .= '<a href="/' . $CategoryName . '/' . freshports_strip_port_suffix($PortName) . '/';
if ($BranchName != BRANCH_HEAD) {
$HTML .= '?branch=' . htmlentities($BranchName);
}
Expand All @@ -193,7 +205,7 @@ function freshports_link_text_to_port_single($text, $CategoryName, $PortName, $B
// This differs from freshports_link_to_port_single in the link text is not necessarily the port name.

$HTML = '';
$HTML .= $text . ' : <a href="/' . $CategoryName . '/' . $PortName . '/';
$HTML .= $text . ' : <a href="/' . $CategoryName . '/' . freshports_strip_port_suffix($PortName) . '/';
if ($BranchName != BRANCH_HEAD) {
$HTML .= '?branch=' . htmlentities($BranchName);
}
Expand Down

0 comments on commit ef10971

Please sign in to comment.