Skip to content

Commit

Permalink
Fix trailing slash issues for SystemURLs::getURL()
Browse files Browse the repository at this point in the history
This function will now always return a URL that does not end with a trailing slash.

Locations in the code that call this function must insert a separator slash as necessary.

Closes #5184
  • Loading branch information
crossan007 committed Mar 23, 2020
1 parent e038f17 commit ea49ff5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/ChurchCRM/dto/SystemURLs.php
Expand Up @@ -72,9 +72,15 @@ public static function getSupportURL($topic="")

}

public static function getURL($index = 0)
public static function getURL($index = 0)
{
return self::$urls[$index];
// Return the URL configured for this server from Include/Config.php
// Trim any trailing slashes from the configured URL
$URL = self::$urls[$index];
if (substr($URL,-1,1) == "/") {
return substr($URL,0,-1);
}
return $URL;
}

private static function isValidRootPath()
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/people/people-family.php
Expand Up @@ -95,7 +95,7 @@
$token->build("verifyFamily", $family->getId());
$token->save();
$family->createTimeLineNote("verify-URL");
return $response->withJSON(["url" => SystemURLs::getURL() . "external/verify/" . $token->getToken()]);
return $response->withJSON(["url" => SystemURLs::getURL() . "/external/verify/" . $token->getToken()]);
});

$this->post('/verify/now', function ($request, $response, $args) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/email/BaseEmail.html
Expand Up @@ -52,7 +52,7 @@ <h2 class="display-3">{{churchName}}</b></h2>
{{/ userName}}
{{# verificationToken}}
<p>
<a href="{{churchCRMURL}}external/verify/{{verificationToken}}" target="_blank">{{churchCRMURL}}external/verify/{{verificationToken}}</a>
<a href="{{churchCRMURL}}/external/verify/{{verificationToken}}" target="_blank">{{churchCRMURL}}/external/verify/{{verificationToken}}</a>
</p>
{{/ verificationToken}}
{{# passwordResetLinkURL}}
Expand Down

0 comments on commit ea49ff5

Please sign in to comment.