diff --git a/changelog.md b/changelog.md index 392aad7..d9e979d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +1.2.2 +=============================== +- Fix uri + 1.2.1 =============================== - Import Tags diff --git a/package.json b/package.json index 21f989b..e6d98cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@modxclub/import-old-site", "description": "Importer for modxclub.ru", - "version": "1.2.1", + "version": "1.2.2", "main": "src/", "files": [ "src" diff --git a/src/modules/processor/index.mjs b/src/modules/processor/index.mjs index 9150b3e..6fd1af6 100644 --- a/src/modules/processor/index.mjs +++ b/src/modules/processor/index.mjs @@ -491,7 +491,7 @@ export default class ImportProcessor extends PrismaProcessor { let result; - const { + let { id, pagetitle: name, createdon, @@ -527,6 +527,8 @@ export default class ImportProcessor extends PrismaProcessor { contentText, } = this.getContent(text) || {}; + uri = this.prepareUri(uri); + /** * Сохраняем объект */ @@ -666,7 +668,7 @@ export default class ImportProcessor extends PrismaProcessor { let result; - const { + let { id, pagetitle: name, createdon, @@ -690,6 +692,8 @@ export default class ImportProcessor extends PrismaProcessor { contentText, } = this.getContent(text) || {}; + uri = this.prepareUri(uri); + /** * Сохраняем объект */ @@ -793,6 +797,7 @@ export default class ImportProcessor extends PrismaProcessor { query.select([ "source.*", + "source.id as oldID", "target_id as topicId", "Topic.name as topicName", "Parent.id as parentId", @@ -841,8 +846,9 @@ export default class ImportProcessor extends PrismaProcessor { let result; - const { + let { id, + oldID, // pagetitle: name, createdon, editedon, @@ -863,7 +869,7 @@ export default class ImportProcessor extends PrismaProcessor { let type = "Comment"; - const uri = `/comments/comment-${id}.html`; + const uri = `/comments/comment-${oldID}.html`; let { content, @@ -1082,6 +1088,19 @@ export default class ImportProcessor extends PrismaProcessor { return root; } + prepareUri(uri){ + + if(!uri){ + throw new Error("uri is empty"); + } + + if(!uri.startsWith("/")){ + uri = `/${uri}`; + } + + return uri; + } + /** * Eof Import Comments */