Merge pull request #3526 from dpalou/MOBILE-4235

MOBILE-4235 h5p: Fix regex applied by dependencies
main
Noel De Martin 2023-01-19 16:31:24 +01:00 committed by GitHub
commit f6e1b2deb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -271,8 +271,13 @@ export class CoreH5PCore {
if (addon.addTo?.content?.types?.length) {
for (let i = 0; i < addon.addTo.content.types.length; i++) {
const type = addon.addTo.content.types[i];
let regex = type?.text?.regex;
if (regex && regex[0] === '/' && regex.slice(-1) === '/') {
// Regex designed for PHP. Remove the starting and ending slashes to convert them to JS format.
regex = regex.substring(1, regex.length - 1);
}
if (type && type.text && type.text.regex && this.textAddonMatches(params.params, type.text.regex)) {
if (regex && this.textAddonMatches(params.params, regex)) {
await validator.addon(addon);
// An addon shall only be added once.