diff --git a/src/addons/badges/services/handlers/badge-link.ts b/src/addons/badges/services/handlers/badge-link.ts index 9012435ec..25b14f5d9 100644 --- a/src/addons/badges/services/handlers/badge-link.ts +++ b/src/addons/badges/services/handlers/badge-link.ts @@ -27,7 +27,7 @@ import { AddonBadges } from '../badges'; export class AddonBadgesBadgeLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonBadgesBadgeLinkHandler'; - pattern = /^\/badges\/badge\.php.*([?&]hash=)/; + pattern = /\/badges\/badge\.php.*([?&]hash=)/; /** * Get the list of actions for a link (url). diff --git a/src/addons/badges/services/handlers/mybadges-link.ts b/src/addons/badges/services/handlers/mybadges-link.ts index 543643dcd..2de022feb 100644 --- a/src/addons/badges/services/handlers/mybadges-link.ts +++ b/src/addons/badges/services/handlers/mybadges-link.ts @@ -27,7 +27,7 @@ export class AddonBadgesMyBadgesLinkHandlerService extends CoreContentLinksHandl name = 'AddonBadgesMyBadgesLinkHandler'; featureName = 'CoreUserDelegate_AddonBadges'; - pattern = /^\/badges\/mybadges\.php/; + pattern = /\/badges\/mybadges\.php/; /** * Get the list of actions for a link (url). diff --git a/src/addons/blog/services/handlers/index-link.ts b/src/addons/blog/services/handlers/index-link.ts index e262c2804..add0dcafb 100644 --- a/src/addons/blog/services/handlers/index-link.ts +++ b/src/addons/blog/services/handlers/index-link.ts @@ -28,7 +28,7 @@ export class AddonBlogIndexLinkHandlerService extends CoreContentLinksHandlerBas name = 'AddonBlogIndexLinkHandler'; featureName = 'CoreUserDelegate_AddonBlog:blogs'; - pattern = /^\/blog\/index\.php/; + pattern = /\/blog\/index\.php/; /** * @inheritdoc diff --git a/src/addons/calendar/services/handlers/view-link.ts b/src/addons/calendar/services/handlers/view-link.ts index 1ebd188ed..45914e697 100644 --- a/src/addons/calendar/services/handlers/view-link.ts +++ b/src/addons/calendar/services/handlers/view-link.ts @@ -30,7 +30,7 @@ const SUPPORTED_VIEWS = ['month', 'mini', 'minithree', 'day', 'upcoming', 'upcom export class AddonCalendarViewLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonCalendarViewLinkHandler'; - pattern = /^\/calendar\/view\.php/; + pattern = /\/calendar\/view\.php/; /** * Get the list of actions for a link (url). diff --git a/src/addons/competency/services/handlers/competency-link.ts b/src/addons/competency/services/handlers/competency-link.ts index 15bc6cc1a..c1ae3bfc5 100644 --- a/src/addons/competency/services/handlers/competency-link.ts +++ b/src/addons/competency/services/handlers/competency-link.ts @@ -29,6 +29,7 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink name = 'AddonCompetencyCompetencyLinkHandler'; pattern = /\/admin\/tool\/lp\/(user_competency_in_course|user_competency_in_plan)\.php/; + patternMatchStart = false; /** * @inheritdoc diff --git a/src/addons/competency/services/handlers/plan-link.ts b/src/addons/competency/services/handlers/plan-link.ts index e38bb136a..01aa234e3 100644 --- a/src/addons/competency/services/handlers/plan-link.ts +++ b/src/addons/competency/services/handlers/plan-link.ts @@ -28,6 +28,7 @@ export class AddonCompetencyPlanLinkHandlerService extends CoreContentLinksHandl name = 'AddonCompetencyPlanLinkHandler'; pattern = /\/admin\/tool\/lp\/plan\.php.*([?&]id=\d+)/; + patternMatchStart = false; /** * @inheritdoc diff --git a/src/addons/competency/services/handlers/plans-link.ts b/src/addons/competency/services/handlers/plans-link.ts index 2f5bddeb4..b88e76723 100644 --- a/src/addons/competency/services/handlers/plans-link.ts +++ b/src/addons/competency/services/handlers/plans-link.ts @@ -28,6 +28,7 @@ export class AddonCompetencyPlansLinkHandlerService extends CoreContentLinksHand name = 'AddonCompetencyPlansLinkHandler'; pattern = /\/admin\/tool\/lp\/plans\.php/; + patternMatchStart = false; /** * @inheritdoc diff --git a/src/addons/competency/services/handlers/user-competency-link.ts b/src/addons/competency/services/handlers/user-competency-link.ts index adbab8a92..d6ddc5210 100644 --- a/src/addons/competency/services/handlers/user-competency-link.ts +++ b/src/addons/competency/services/handlers/user-competency-link.ts @@ -28,6 +28,7 @@ export class AddonCompetencyUserCompetencyLinkHandlerService extends CoreContent name = 'AddonCompetencyUserCompetencyLinkHandler'; pattern = /\/admin\/tool\/lp\/user_competency\.php.*([?&]id=\d+)/; + patternMatchStart = false; /** * @inheritdoc diff --git a/src/addons/messages/services/handlers/contact-request-link.ts b/src/addons/messages/services/handlers/contact-request-link.ts index bb787113b..a06eb6e11 100644 --- a/src/addons/messages/services/handlers/contact-request-link.ts +++ b/src/addons/messages/services/handlers/contact-request-link.ts @@ -26,7 +26,7 @@ import { AddonMessages } from '../messages'; export class AddonMessagesContactRequestLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonMessagesContactRequestLinkHandler'; - pattern = /^\/message\/pendingcontactrequests\.php/; + pattern = /\/message\/pendingcontactrequests\.php/; /** * Get the list of actions for a link (url). diff --git a/src/addons/messages/services/handlers/discussion-link.ts b/src/addons/messages/services/handlers/discussion-link.ts index 3276ee859..2eb03cdec 100644 --- a/src/addons/messages/services/handlers/discussion-link.ts +++ b/src/addons/messages/services/handlers/discussion-link.ts @@ -29,7 +29,7 @@ import { AddonMessages } from '../messages'; export class AddonMessagesDiscussionLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonMessagesDiscussionLinkHandler'; - pattern = /^\/message\/index\.php.*([?&](id|user1|user2)=\d+)/; + pattern = /\/message\/index\.php.*([?&](id|user1|user2)=\d+)/; /** * Get the list of actions for a link (url). diff --git a/src/addons/messages/services/handlers/index-link.ts b/src/addons/messages/services/handlers/index-link.ts index 34f294340..d552a6886 100644 --- a/src/addons/messages/services/handlers/index-link.ts +++ b/src/addons/messages/services/handlers/index-link.ts @@ -28,7 +28,7 @@ import { AddonMessagesMainMenuHandlerService } from './mainmenu'; export class AddonMessagesIndexLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonMessagesIndexLinkHandler'; - pattern = /^\/message\/index\.php((?![?&](id|user1|user2)=\d+).)*$/; + pattern = /\/message\/index\.php((?![?&](id|user1|user2)=\d+).)*$/; /** * Get the list of actions for a link (url). diff --git a/src/addons/mod/data/services/handlers/approve-link.ts b/src/addons/mod/data/services/handlers/approve-link.ts index 1e24c9d8d..f6802bca2 100644 --- a/src/addons/mod/data/services/handlers/approve-link.ts +++ b/src/addons/mod/data/services/handlers/approve-link.ts @@ -28,7 +28,7 @@ export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandl name = 'AddonModDataApproveLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModData'; - pattern = /^\/mod\/data\/view\.php.*([?&](d|approve|disapprove)=\d+)/; + pattern = /\/mod\/data\/view\.php.*([?&](d|approve|disapprove)=\d+)/; priority = 50; // Higher priority than the default link handler for view.php. /** diff --git a/src/addons/mod/data/services/handlers/delete-link.ts b/src/addons/mod/data/services/handlers/delete-link.ts index f18a54e54..71b0d8125 100644 --- a/src/addons/mod/data/services/handlers/delete-link.ts +++ b/src/addons/mod/data/services/handlers/delete-link.ts @@ -28,7 +28,7 @@ export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandle name = 'AddonModDataDeleteLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModData'; - pattern = /^\/mod\/data\/view\.php.*([?&](d|delete)=\d+)/; + pattern = /\/mod\/data\/view\.php.*([?&](d|delete)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/data/services/handlers/edit-link.ts b/src/addons/mod/data/services/handlers/edit-link.ts index 135c12b3d..bcabe86bd 100644 --- a/src/addons/mod/data/services/handlers/edit-link.ts +++ b/src/addons/mod/data/services/handlers/edit-link.ts @@ -32,7 +32,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB name = 'AddonModDataEditLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModData'; - pattern = /^\/mod\/data\/edit\.php.*([?&](d|rid)=\d+)/; + pattern = /\/mod\/data\/edit\.php.*([?&](d|rid)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/data/services/handlers/show-link.ts b/src/addons/mod/data/services/handlers/show-link.ts index 5050c4c90..f30535768 100644 --- a/src/addons/mod/data/services/handlers/show-link.ts +++ b/src/addons/mod/data/services/handlers/show-link.ts @@ -32,7 +32,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB name = 'AddonModDataShowLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModData'; - pattern = /^\/mod\/data\/view\.php.*([?&](d|rid|page|group|mode)=\d+)/; + pattern = /\/mod\/data\/view\.php.*([?&](d|rid|page|group|mode)=\d+)/; priority = 50; // Higher priority than the default link handler for view.php. /** diff --git a/src/addons/mod/feedback/services/handlers/analysis-link.ts b/src/addons/mod/feedback/services/handlers/analysis-link.ts index 0549950cc..f1b38c0dc 100644 --- a/src/addons/mod/feedback/services/handlers/analysis-link.ts +++ b/src/addons/mod/feedback/services/handlers/analysis-link.ts @@ -30,7 +30,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks name = 'AddonModFeedbackAnalysisLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; - pattern = /^\/mod\/feedback\/analysis\.php.*([&?]id=\d+)/; + pattern = /\/mod\/feedback\/analysis\.php.*([&?]id=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/feedback/services/handlers/complete-link.ts b/src/addons/mod/feedback/services/handlers/complete-link.ts index c5154243a..7ae34e1a5 100644 --- a/src/addons/mod/feedback/services/handlers/complete-link.ts +++ b/src/addons/mod/feedback/services/handlers/complete-link.ts @@ -31,7 +31,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks name = 'AddonModFeedbackCompleteLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; - pattern = /^\/mod\/feedback\/complete\.php.*([?&](id|gopage)=\d+)/; + pattern = /\/mod\/feedback\/complete\.php.*([?&](id|gopage)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/feedback/services/handlers/print-link.ts b/src/addons/mod/feedback/services/handlers/print-link.ts index 9c5f09f11..bb6d4d099 100644 --- a/src/addons/mod/feedback/services/handlers/print-link.ts +++ b/src/addons/mod/feedback/services/handlers/print-link.ts @@ -31,7 +31,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan name = 'AddonModFeedbackPrintLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; - pattern = /^\/mod\/feedback\/print\.php.*([?&](id)=\d+)/; + pattern = /\/mod\/feedback\/print\.php.*([?&](id)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/feedback/services/handlers/show-entries-link.ts b/src/addons/mod/feedback/services/handlers/show-entries-link.ts index b3d83cf79..30f3b7c15 100644 --- a/src/addons/mod/feedback/services/handlers/show-entries-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-entries-link.ts @@ -27,7 +27,7 @@ export class AddonModFeedbackShowEntriesLinkHandlerService extends CoreContentLi name = 'AddonModFeedbackShowEntriesLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; - pattern = /^\/mod\/feedback\/show_entries\.php.*([?&](id|showcompleted)=\d+)/; + pattern = /\/mod\/feedback\/show_entries\.php.*([?&](id|showcompleted)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts index 207808a6b..ea6e054ef 100644 --- a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts @@ -30,7 +30,7 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo name = 'AddonModFeedbackShowNonRespondentsLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModFeedback'; - pattern = /^\/mod\/feedback\/show_nonrespondents\.php.*([?&](id)=\d+)/; + pattern = /\/mod\/feedback\/show_nonrespondents\.php.*([?&](id)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/forum/services/handlers/discussion-link.ts b/src/addons/mod/forum/services/handlers/discussion-link.ts index babfcd8a1..922ccf4a1 100644 --- a/src/addons/mod/forum/services/handlers/discussion-link.ts +++ b/src/addons/mod/forum/services/handlers/discussion-link.ts @@ -28,7 +28,7 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH name = 'AddonModForumDiscussionLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModForum'; - pattern = /^\/mod\/forum\/discuss\.php.*([&?]d=\d+)/; + pattern = /\/mod\/forum\/discuss\.php.*([&?]d=\d+)/; /** * Get the list of actions for a link (url). diff --git a/src/addons/mod/forum/services/handlers/post-link.ts b/src/addons/mod/forum/services/handlers/post-link.ts index a404d38e3..4349b2aa9 100644 --- a/src/addons/mod/forum/services/handlers/post-link.ts +++ b/src/addons/mod/forum/services/handlers/post-link.ts @@ -32,7 +32,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler name = 'AddonModForumPostLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModForum'; - pattern = /^\/mod\/forum\/post\.php.*([?&](forum)=\d+)/; + pattern = /\/mod\/forum\/post\.php.*([?&](forum)=\d+)/; /** * Get the list of actions for a link (url). diff --git a/src/addons/mod/glossary/services/handlers/edit-link.ts b/src/addons/mod/glossary/services/handlers/edit-link.ts index d9a08609e..8859a6d72 100644 --- a/src/addons/mod/glossary/services/handlers/edit-link.ts +++ b/src/addons/mod/glossary/services/handlers/edit-link.ts @@ -32,7 +32,7 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand name = 'AddonModGlossaryEditLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModGlossary'; - pattern = /^\/mod\/glossary\/edit\.php.*([?&](cmid)=\d+)/; + pattern = /\/mod\/glossary\/edit\.php.*([?&](cmid)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/glossary/services/handlers/entry-link.ts b/src/addons/mod/glossary/services/handlers/entry-link.ts index 3a7fcbf87..d58a0bac3 100644 --- a/src/addons/mod/glossary/services/handlers/entry-link.ts +++ b/src/addons/mod/glossary/services/handlers/entry-link.ts @@ -31,7 +31,7 @@ export class AddonModGlossaryEntryLinkHandlerService extends CoreContentLinksHan name = 'AddonModGlossaryEntryLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModGlossary'; - pattern = /^\/mod\/glossary\/(showentry|view)\.php.*([&?](eid|g|mode|hook)=\d+)/; + pattern = /\/mod\/glossary\/(showentry|view)\.php.*([&?](eid|g|mode|hook)=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/h5pactivity/services/handlers/report-link.ts b/src/addons/mod/h5pactivity/services/handlers/report-link.ts index c72f6e541..f3272d2bf 100644 --- a/src/addons/mod/h5pactivity/services/handlers/report-link.ts +++ b/src/addons/mod/h5pactivity/services/handlers/report-link.ts @@ -33,7 +33,7 @@ export class AddonModH5PActivityReportLinkHandlerService extends CoreContentLink name = 'AddonModH5PActivityReportLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModH5PActivity'; - pattern = /^\/mod\/h5pactivity\/report\.php.*([&?]a=\d+)/; + pattern = /\/mod\/h5pactivity\/report\.php.*([&?]a=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/lesson/services/handlers/report-link.ts b/src/addons/mod/lesson/services/handlers/report-link.ts index 08d599b31..355476434 100644 --- a/src/addons/mod/lesson/services/handlers/report-link.ts +++ b/src/addons/mod/lesson/services/handlers/report-link.ts @@ -31,7 +31,7 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand name = 'AddonModLessonReportLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModLesson'; - pattern = /^\/mod\/lesson\/report\.php.*([&?]id=\d+)/; + pattern = /\/mod\/lesson\/report\.php.*([&?]id=\d+)/; /** * Get the list of actions for a link (url). diff --git a/src/addons/mod/quiz/services/handlers/review-link.ts b/src/addons/mod/quiz/services/handlers/review-link.ts index ebd3d50ec..d2c7cdd3b 100644 --- a/src/addons/mod/quiz/services/handlers/review-link.ts +++ b/src/addons/mod/quiz/services/handlers/review-link.ts @@ -26,7 +26,7 @@ export class AddonModQuizReviewLinkHandlerService extends CoreContentLinksHandle name = 'AddonModQuizReviewLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModQuiz'; - pattern = /^\/mod\/quiz\/review\.php.*([&?]attempt=\d+)/; + pattern = /\/mod\/quiz\/review\.php.*([&?]attempt=\d+)/; /** * Get the list of actions for a link (url). diff --git a/src/addons/mod/wiki/services/handlers/create-link.ts b/src/addons/mod/wiki/services/handlers/create-link.ts index 79efa5cf4..b78a3f632 100644 --- a/src/addons/mod/wiki/services/handlers/create-link.ts +++ b/src/addons/mod/wiki/services/handlers/create-link.ts @@ -33,7 +33,7 @@ export class AddonModWikiCreateLinkHandlerService extends CoreContentLinksHandle name = 'AddonModWikiCreateLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModWiki'; - pattern = /^\/mod\/wiki\/create\.php.*([&?]swid=\d+)/; + pattern = /\/mod\/wiki\/create\.php.*([&?]swid=\d+)/; /** * Check if the current view is a wiki page of the same wiki. diff --git a/src/addons/mod/wiki/services/handlers/edit-link.ts b/src/addons/mod/wiki/services/handlers/edit-link.ts index 3aafc53dd..68e3a5140 100644 --- a/src/addons/mod/wiki/services/handlers/edit-link.ts +++ b/src/addons/mod/wiki/services/handlers/edit-link.ts @@ -31,7 +31,7 @@ export class AddonModWikiEditLinkHandlerService extends CoreContentLinksHandlerB name = 'AddonModWikiEditLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModWiki'; - pattern = /^\/mod\/wiki\/edit\.php.*([&?]pageid=\d+)/; + pattern = /\/mod\/wiki\/edit\.php.*([&?]pageid=\d+)/; /** * @inheritdoc diff --git a/src/addons/mod/wiki/services/handlers/page-or-map-link.ts b/src/addons/mod/wiki/services/handlers/page-or-map-link.ts index 4bd476fde..9b995e3bd 100644 --- a/src/addons/mod/wiki/services/handlers/page-or-map-link.ts +++ b/src/addons/mod/wiki/services/handlers/page-or-map-link.ts @@ -32,7 +32,7 @@ export class AddonModWikiPageOrMapLinkHandlerService extends CoreContentLinksHan name = 'AddonModWikiPageOrMapLinkHandler'; featureName = 'CoreCourseModuleDelegate_AddonModWiki'; - pattern = /^\/mod\/wiki\/(view|map)\.php.*([&?]pageid=\d+)/; + pattern = /\/mod\/wiki\/(view|map)\.php.*([&?]pageid=\d+)/; /** * @inheritdoc diff --git a/src/addons/notifications/services/handlers/notifications-link.ts b/src/addons/notifications/services/handlers/notifications-link.ts index a3b17bb5f..9d560d165 100644 --- a/src/addons/notifications/services/handlers/notifications-link.ts +++ b/src/addons/notifications/services/handlers/notifications-link.ts @@ -27,7 +27,7 @@ import { AddonNotificationsMainMenuHandlerService } from './mainmenu'; export class AddonNotificationsLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonNotificationsLinkHandler'; - pattern = /^\/message\/output\/popup\/notifications\.php/; + pattern = /\/message\/output\/popup\/notifications\.php/; featureName = 'CoreMainMenuDelegate_AddonNotifications'; /** diff --git a/src/addons/notifications/services/handlers/preferences-link.ts b/src/addons/notifications/services/handlers/preferences-link.ts index 5da2ae898..a2ab6da07 100644 --- a/src/addons/notifications/services/handlers/preferences-link.ts +++ b/src/addons/notifications/services/handlers/preferences-link.ts @@ -28,7 +28,7 @@ import { AddonNotificationsSettingsHandlerService } from './settings'; export class AddonNotificationsPreferencesLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonNotificationsPreferencesLinkHandler'; - pattern = /^\/message\/notificationpreferences\.php/; + pattern = /\/message\/notificationpreferences\.php/; checkAllUsers = true; featureName = 'CoreMainMenuDelegate_AddonNotifications'; diff --git a/src/addons/report/insights/services/handlers/action-link.ts b/src/addons/report/insights/services/handlers/action-link.ts index e5f91b406..aad2a84fc 100644 --- a/src/addons/report/insights/services/handlers/action-link.ts +++ b/src/addons/report/insights/services/handlers/action-link.ts @@ -38,7 +38,7 @@ const BULK_ACTIONS = { export class AddonReportInsightsActionLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonReportInsightsActionLinkHandler'; - pattern = /^\/report\/insights\/action\.php/; + pattern = /\/report\/insights\/action\.php/; /** * @inheritdoc diff --git a/src/core/features/contentlinks/classes/base-handler.ts b/src/core/features/contentlinks/classes/base-handler.ts index 2ac903131..2e9199796 100644 --- a/src/core/features/contentlinks/classes/base-handler.ts +++ b/src/core/features/contentlinks/classes/base-handler.ts @@ -50,6 +50,11 @@ export class CoreContentLinksHandlerBase implements CoreContentLinksHandler { */ pattern?: RegExp; + /** + * If true, a "^" will be added to the beginning of the pattern. It's recommended to avoid collisions with other handlers. + */ + patternMatchStart = true; + /** * Get the list of actions for a link (url). * @@ -82,7 +87,15 @@ export class CoreContentLinksHandlerBase implements CoreContentLinksHandler { * @return Whether the URL is handled by this handler */ handles(url: string): boolean { - return !!this.pattern && url.search(this.pattern) >= 0; + let pattern = this.pattern; + + if (pattern && this.patternMatchStart) { + let patternString = pattern.toString(); + patternString = patternString.substring(1, patternString.length - 1); // Remove slashes from beginning and end. + pattern = new RegExp('^' + patternString); + } + + return !!pattern && url.search(pattern) >= 0; } /** diff --git a/src/core/features/contentlinks/classes/module-grade-handler.ts b/src/core/features/contentlinks/classes/module-grade-handler.ts index 88e416ef8..cce3bad41 100644 --- a/src/core/features/contentlinks/classes/module-grade-handler.ts +++ b/src/core/features/contentlinks/classes/module-grade-handler.ts @@ -47,7 +47,7 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB super(); // Match the grade.php URL with an id param. - this.pattern = new RegExp('^/mod/' + modName + '/grade.php.*([&?]id=\\d+)'); + this.pattern = new RegExp('/mod/' + modName + '/grade.php.*([&?]id=\\d+)'); this.featureName = 'CoreCourseModuleDelegate_' + addon; } diff --git a/src/core/features/contentlinks/classes/module-index-handler.ts b/src/core/features/contentlinks/classes/module-index-handler.ts index 5910de0eb..685970110 100644 --- a/src/core/features/contentlinks/classes/module-index-handler.ts +++ b/src/core/features/contentlinks/classes/module-index-handler.ts @@ -45,8 +45,8 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB // Match the view.php URL with an id or instance id param. const pattern = instanceIdParam ? - '^/mod/' + modName + '/view.php.*([&?](' + instanceIdParam + '|id)=\\d+)' : - '^/mod/' + modName + '/view.php.*([&?]id=\\d+)'; + '/mod/' + modName + '/view.php.*([&?](' + instanceIdParam + '|id)=\\d+)' : + '/mod/' + modName + '/view.php.*([&?]id=\\d+)'; this.pattern = new RegExp(pattern); this.featureName = 'CoreCourseModuleDelegate_' + addon; diff --git a/src/core/features/contentlinks/classes/module-list-handler.ts b/src/core/features/contentlinks/classes/module-list-handler.ts index a20e8cf41..e8fd0a3f0 100644 --- a/src/core/features/contentlinks/classes/module-list-handler.ts +++ b/src/core/features/contentlinks/classes/module-list-handler.ts @@ -41,7 +41,7 @@ export class CoreContentLinksModuleListHandler extends CoreContentLinksHandlerBa super(); // Match the index.php URL with an id param. - this.pattern = new RegExp('^/mod/' + modName + '/index.php.*([&?]id=\\d+)'); + this.pattern = new RegExp('/mod/' + modName + '/index.php.*([&?]id=\\d+)'); this.featureName = 'CoreCourseModuleDelegate_' + addon; } diff --git a/src/core/features/courses/services/handlers/course-link.ts b/src/core/features/courses/services/handlers/course-link.ts index b8d847a96..5c7347844 100644 --- a/src/core/features/courses/services/handlers/course-link.ts +++ b/src/core/features/courses/services/handlers/course-link.ts @@ -35,7 +35,7 @@ import { CoreIonLoadingElement } from '@classes/ion-loading'; export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreCoursesCourseLinkHandler'; - pattern = /((^\/enrol\/index\.php)|(^\/course\/enrol\.php)|(^\/course\/view\.php)).*([?&]id=\d+)/; + pattern = /((\/enrol\/index\.php)|(\/course\/enrol\.php)|(\/course\/view\.php)).*([?&]id=\d+)/; protected waitStart = 0; protected logger: CoreLogger; diff --git a/src/core/features/courses/services/handlers/courses-index-link.ts b/src/core/features/courses/services/handlers/courses-index-link.ts index e486728ab..4ca26a580 100644 --- a/src/core/features/courses/services/handlers/courses-index-link.ts +++ b/src/core/features/courses/services/handlers/courses-index-link.ts @@ -28,7 +28,7 @@ export class CoreCoursesIndexLinkHandlerService extends CoreContentLinksHandlerB name = 'CoreCoursesIndexLinkHandler'; featureName = 'CoreMainMenuDelegate_CoreCourses'; - pattern = /^\/course\/?(index\.php.*)?$/; + pattern = /\/course\/?(index\.php.*)?$/; /** * @inheritdoc diff --git a/src/core/features/courses/services/handlers/dashboard-link.ts b/src/core/features/courses/services/handlers/dashboard-link.ts index 24af04dc3..05ad995a0 100644 --- a/src/core/features/courses/services/handlers/dashboard-link.ts +++ b/src/core/features/courses/services/handlers/dashboard-link.ts @@ -27,7 +27,7 @@ import { CoreDashboardHomeHandler, CoreDashboardHomeHandlerService } from './das export class CoreCoursesDashboardLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreCoursesDashboardLinkHandler'; - pattern = /^\/my\/?$/; + pattern = /\/my\/?$/; /** * Get the list of actions for a link (url). diff --git a/src/core/features/grades/services/handlers/overview-link.ts b/src/core/features/grades/services/handlers/overview-link.ts index 844c8ea69..2205e29ea 100644 --- a/src/core/features/grades/services/handlers/overview-link.ts +++ b/src/core/features/grades/services/handlers/overview-link.ts @@ -27,7 +27,7 @@ import { GRADES_PAGE_NAME } from '../grades-helper'; export class CoreGradesOverviewLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreGradesOverviewLinkHandler'; - pattern = /^\/grade\/report\/overview\/index.php/; + pattern = /\/grade\/report\/overview\/index.php/; /** * Get the list of actions for a link (url). diff --git a/src/core/features/grades/services/handlers/report-link.ts b/src/core/features/grades/services/handlers/report-link.ts index 9f5e9da61..1efed0df7 100644 --- a/src/core/features/grades/services/handlers/report-link.ts +++ b/src/core/features/grades/services/handlers/report-link.ts @@ -27,7 +27,7 @@ import { makeSingleton } from '@singletons'; export class CoreGradesReportLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreGradesReportLinkHandler'; - pattern = /^\/grade\/report(\/user)?\/index.php/; + pattern = /\/grade\/report(\/user)?\/index.php/; /** * Get the list of actions for a link (url). diff --git a/src/core/features/grades/services/handlers/user-link.ts b/src/core/features/grades/services/handlers/user-link.ts index 2616e9688..1f1ba4008 100644 --- a/src/core/features/grades/services/handlers/user-link.ts +++ b/src/core/features/grades/services/handlers/user-link.ts @@ -27,7 +27,7 @@ import { makeSingleton } from '@singletons'; export class CoreGradesUserLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreGradesUserLinkHandler'; - pattern = /^\/course\/user\.php.*[?&]mode=grade/; + pattern = /\/course\/user\.php.*[?&]mode=grade/; /** * Get the list of actions for a link (url). diff --git a/src/core/features/sitehome/services/handlers/index-link.ts b/src/core/features/sitehome/services/handlers/index-link.ts index 017a14d0c..61850ca27 100644 --- a/src/core/features/sitehome/services/handlers/index-link.ts +++ b/src/core/features/sitehome/services/handlers/index-link.ts @@ -31,7 +31,7 @@ export class CoreSiteHomeIndexLinkHandlerService extends CoreContentLinksHandler name = 'CoreSiteHomeIndexLinkHandler'; featureName = 'CoreMainMenuDelegate_CoreSiteHome'; - pattern = /^\/course\/view\.php.*([?&]id=\d+)|^\/index\.php(\?redirect=0)?/; + pattern = /(\/course\/view\.php.*([?&]id=\d+)|\/index\.php(\?redirect=0)?)/; /** * @inheritdoc diff --git a/src/core/features/tag/services/handlers/index-link.ts b/src/core/features/tag/services/handlers/index-link.ts index 5e60dec7f..6454bbdb9 100644 --- a/src/core/features/tag/services/handlers/index-link.ts +++ b/src/core/features/tag/services/handlers/index-link.ts @@ -27,7 +27,7 @@ import { CoreTag } from '../tag'; export class CoreTagIndexLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreTagIndexLinkHandler'; - pattern = /^\/tag\/index\.php/; + pattern = /\/tag\/index\.php/; /** * Get the list of actions for a link (url). diff --git a/src/core/features/tag/services/handlers/search-link.ts b/src/core/features/tag/services/handlers/search-link.ts index c97c07a7f..1749af16a 100644 --- a/src/core/features/tag/services/handlers/search-link.ts +++ b/src/core/features/tag/services/handlers/search-link.ts @@ -27,7 +27,7 @@ import { CoreTag } from '../tag'; export class CoreTagSearchLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreTagSearchLinkHandler'; - pattern = /^\/tag\/search\.php/; + pattern = /\/tag\/search\.php/; /** * Get the list of actions for a link (url). diff --git a/src/core/features/user/services/handlers/profile-link.ts b/src/core/features/user/services/handlers/profile-link.ts index 18fd695f1..b7eb0ad5b 100644 --- a/src/core/features/user/services/handlers/profile-link.ts +++ b/src/core/features/user/services/handlers/profile-link.ts @@ -27,7 +27,7 @@ export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBa name = 'CoreUserProfileLinkHandler'; // Match user/view.php and user/profile.php but NOT grade/report/user/. - pattern = /((^\/user\/view\.php)|(^\/user\/profile\.php)).*([?&]id=\d+)/; + pattern = /((\/user\/view\.php)|(\/user\/profile\.php)).*([?&]id=\d+)/; /** * Get the list of actions for a link (url). diff --git a/upgrade.txt b/upgrade.txt index 0923819d3..2ee2fb749 100644 --- a/upgrade.txt +++ b/upgrade.txt @@ -24,7 +24,7 @@ information provided here is intended especially for developers. - contextMenuPrefetch and fillContextMenu have been removed from CoreCourseHelper. - The variable "loaded" in CoreCourseModuleMainResourceComponent has been changed to "showLoading" to reflect its purpose better. - The function getCurrentSection of course formats can now return a forceSelected boolean along with the section (defaults to false if not returned). -- The link handlers functions (CoreContentLinksHandler) will now always receive a relative URL instead of an absolute URL. It's now recommended to use "^" in your regular expressions to avoid false positives. +- The link handlers functions (CoreContentLinksHandler) will now always receive a relative URL instead of an absolute URL. The CoreContentLinksHandlerBase class now adds "^" to the start of the pattern by default to prevent false positives.