Skip to content

Commit 022509d

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/missing-operations
# Conflicts: # package-lock.json # package.json # src/strategies/document-group.strategy.ts
2 parents 192df9f + 67ba064 commit 022509d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

.github/workflows/frontend-ci.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ on:
44
push:
55
branches:
66
- release
7+
- hotfix
78
- develop
89
- feature/*
10+
- bugfix/*
911
tags:
1012
- '**'
1113
delete:
12-
branches:
13-
- release
14-
- feature/*
1514

1615
jobs:
1716
call-frontend-ci-workflow:

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netcracker/qubership-apihub-api-processor",
3-
"version": "3.0.5-feature-missing-operations.2",
3+
"version": "3.0.6",
44
"description": "",
55
"license": "Apache-2.0",
66
"module": "dist/esm/src/index.js",

src/strategies/document-group.strategy.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { REST_API_TYPE } from '../apitypes'
2828
import {
2929
EXPORT_FORMAT_TO_FILE_FORMAT,
3030
fromBase64,
31+
getDocumentTitle,
32+
getFileExtension,
3133
removeFirstSlash,
3234
slugify,
3335
takeIfDefined,
@@ -95,7 +97,7 @@ export class DocumentGroupStrategy implements BuilderStrategy {
9597
}
9698

9799
const transformedDocuments = await Promise.all(transformTasks)
98-
const transformedDocumentsWithoutCollisions = (['fileId', 'filename'] as const).reduce(resolveCollisions, transformedDocuments)
100+
const transformedDocumentsWithoutCollisions = (['fileId', 'filename'] as const).reduce(resolveCollisionsByField, transformedDocuments)
99101

100102
for (const document of transformedDocumentsWithoutCollisions) {
101103
buildResult.documents.set(document.fileId, document)
@@ -106,19 +108,18 @@ export class DocumentGroupStrategy implements BuilderStrategy {
106108
}
107109

108110
// there is a chance that the renamed document will be the same as another document (this case has not been fixed yet)
109-
function resolveCollisions(docs: VersionRestDocument[], field: 'fileId' | 'filename'): VersionRestDocument[] {
111+
function resolveCollisionsByField(docs: VersionRestDocument[], field: 'fileId' | 'filename'): VersionRestDocument[] {
110112
const fileIdMap = groupBy(docs, (document) => document[field])
111113
return ([...fileIdMap.values()] as VersionRestDocument[][]).reduce((acc, docs) => {
112114
const [_, ...duplicates] = docs
113-
duplicates.forEach((document, index) => {document[field] = rename(document[field], index)})
115+
duplicates.forEach((document, index) => {document[field] = renameDuplicate(document[field], index)})
114116
return [...acc, ...docs]
115117
}, [] as VersionRestDocument[])
116118
}
117119

118-
function rename(fileName: string, index: number): string {
119-
const nameParts = fileName.split('.')
120-
const extension = nameParts.length > 1 ? nameParts[nameParts?.length - 1] : ''
121-
const nameWithPostfix = `${nameParts[0]} ${index + 1}`
120+
function renameDuplicate(fileName: string, index: number): string {
121+
const extension = getFileExtension(fileName)
122+
const nameWithPostfix = `${getDocumentTitle(fileName)}-${index + 1}`
122123

123124
if (extension) {
124125
return `${nameWithPostfix}.${extension}`

0 commit comments

Comments
 (0)