MOBILE-3615 url: Fix docs url release number
parent
972e1e2a81
commit
07d05d0a26
|
@ -668,6 +668,21 @@ export class CoreSitesProvider {
|
|||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the major release number from site release info.
|
||||
*
|
||||
* @param rawRelease Raw release info text.
|
||||
* @return Major release number or empty.
|
||||
*/
|
||||
getMajorReleaseNumber(rawRelease: string): string {
|
||||
const matches = rawRelease.match(/^\d+(\.\d+)?/);
|
||||
if (matches) {
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a site in local DB.
|
||||
*
|
||||
|
|
|
@ -20,6 +20,7 @@ import { CoreConstants } from '@/core/constants';
|
|||
import { makeSingleton } from '@singletons';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
||||
/*
|
||||
* "Utils" service with helper functions for URLs.
|
||||
|
@ -233,7 +234,8 @@ export class CoreUrlUtilsProvider {
|
|||
let docsUrl = 'https://docs.moodle.org/en/' + page;
|
||||
|
||||
if (typeof release != 'undefined') {
|
||||
const version = release.substr(0, 3).replace('.', '');
|
||||
const version = CoreSites.getMajorReleaseNumber(release).replace('.', '');
|
||||
|
||||
// Check is a valid number.
|
||||
if (Number(version) >= 24) {
|
||||
// Append release number.
|
||||
|
|
Loading…
Reference in New Issue