From b4e7ee4e2185f7b997aec4105a7a3c876607fd35 Mon Sep 17 00:00:00 2001 From: Ryan Smith <3045513+ryansmith94@users.noreply.github.com> Date: Mon, 16 Jul 2018 11:55:32 +0100 Subject: [PATCH] fix: Fixes endpoint correction to close #184. (#187) --- src/loader/lrs.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/loader/lrs.php b/src/loader/lrs.php index c3a5b3a..bf2515e 100644 --- a/src/loader/lrs.php +++ b/src/loader/lrs.php @@ -18,9 +18,11 @@ namespace src\loader\lrs; defined('MOODLE_INTERNAL') || die(); function correct_endpoint($endpoint) { - $nostatements = trim($endpoint, 'statements'); - $noslash = trim($nostatements, '/'); - return $noslash; + $endswithstatements = substr($endpoint, -11) === "/statements"; + if ($endswithstatements) { + return substr($endpoint, 0, -11); + } + return rtrim($endpoint, '/'); } function load_transormed_events_to_lrs(array $config, array $transformedevents) { -- GitLab