Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding_validation_of_sitemapVersion_before_import_of_sitemap #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@
"sitemapmodel_empty_message": { "message": "Empty value is possible model" },
"sitemapjson_invalid_message": { "message": "JSON is not valid" },
"sitemapjson_empty_message": { "message": "Sitemap JSON is required and cannot be empty" },
"sitemap_invalid_specificationVersion": {
"message": "The version of the sitemap is younger than the plugin version. Please update the plugin"
},
"sitemap_url_pattern_empty_message": {
"message": "URL pattern is required and can't be empty"
},
Expand Down
3 changes: 3 additions & 0 deletions src/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@
"sitemapjson_empty_message": {
"message": "JSON карта обхода обязателен и не может быть пустым"
},
"sitemap_invalid_specificationVersion": {
"message": "Версия карты обхода новее чем версия плагина. Пожалуйста обновите плагин"
},
"sitemap_url_pattern_empty_message": { "message": "Шаблон URL не может быть пустым" },
"sitemap_url_pattern_invalid_message": {
"message": "Шаблон URL должен быть корректным регулярным выражением"
Expand Down
19 changes: 17 additions & 2 deletions src/scripts/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SelectorList from './SelectorList';
import SelectorTable from './Selector/SelectorTable';
import Model from './Model';
import Translator from './Translator';

import SitemapSpecMigrationManager from './SitemapSpecMigration/Manager';
export default class SitemapController {
constructor(store, templateDir) {
this.store = store;
Expand Down Expand Up @@ -609,7 +609,22 @@ export default class SitemapController {
};
}
}

// check sitemapSpecificationVersion not younger than plugin version
if (sitemap.hasOwnProperty('sitemapSpecificationVersion')) {
const versionOfSitemap =
sitemap.sitemapSpecificationVersion;
if (
versionOfSitemap >
SitemapSpecMigrationManager.currentVersion()
) {
return {
valid: false,
message: Translator.getTranslationByKey(
'sitemap_invalid_specificationVersion'
),
};
}
}
// check for start urls or url pattern
if (
Object.hasOwn(sitemap, 'startUrls') &&
Expand Down