From fc9835b03536401354905bff6a6ee51c55ccb6fe Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 31 Jul 2018 09:48:13 +0200 Subject: [PATCH] MOBILE-2501 course: Retrieve section number from hash in course links --- src/core/courses/providers/course-link-handler.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/courses/providers/course-link-handler.ts b/src/core/courses/providers/course-link-handler.ts index 1720cb9b6..f346f80c2 100644 --- a/src/core/courses/providers/course-link-handler.ts +++ b/src/core/courses/providers/course-link-handler.ts @@ -58,6 +58,14 @@ export class CoreCoursesCourseLinkHandler extends CoreContentLinksHandlerBase { sectionId: sectionId || null }; + if (!sectionId && !sectionNumber) { + // Check if the URL has a hash to navigate to the section. + const matches = url.match(/#section-(\d+)/); + if (matches && matches[1]) { + sectionNumber = parseInt(matches[1], 10); + } + } + if (!isNaN(sectionNumber)) { pageParams.sectionNumber = sectionNumber; }