Merge pull request #1447 from dpalou/MOBILE-2501

MOBILE-2501 course: Retrieve section number from hash in course links
main
Juan Leyva 2018-08-21 16:24:57 +01:00 committed by GitHub
commit b60325947c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -58,6 +58,14 @@ export class CoreCoursesCourseLinkHandler extends CoreContentLinksHandlerBase {
sectionId: sectionId || null 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)) { if (!isNaN(sectionNumber)) {
pageParams.sectionNumber = sectionNumber; pageParams.sectionNumber = sectionNumber;
} }