Skip to content

Commit fbad5c9

Browse files
fix(issue-sync): Use string.fileId instead of string.file.id (#12)
1 parent 667ce76 commit fbad5c9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/sync-crowdin-issues.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ function buildIssueBody(crowdinIssue, projectId, projectSlug) {
395395
// URL format: /editor/{slug}/{fileId}/en-{normalizedLang}?view=comfortable#{stringId}
396396
// The language segment strips hyphens and lowercases (e.g. "zh-CN" → "en-zhcn").
397397
const stringId = crowdinIssue.string?.id;
398-
const fileId = crowdinIssue.string?.file?.id;
398+
const fileId = crowdinIssue.string?.fileId;
399399
let crowdinUrl;
400400
if (projectSlug && crowdinIssue.languageId && fileId && stringId) {
401401
const normalizedLang = crowdinIssue.languageId.replaceAll(/[-_]/g, '').toLowerCase();

tests/sync-crowdin-issues.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,18 +558,18 @@ describe('buildIssueBody', () => {
558558
});
559559

560560
it('links directly to the string in the editor when slug, file.id and string.id are present', () => {
561-
const issue = { ...baseIssue, languageId: 'fr', string: { text: 'Source', id: 999, file: { id: 5842 } } };
561+
const issue = { ...baseIssue, languageId: 'fr', string: { text: 'Source', id: 999, fileId: 5842 } };
562562
const body = buildIssueBody(issue, projectId, 'my-project');
563563
expect(body).toContain('https://crowdin.com/editor/my-project/5842/en-fr?view=comfortable#999');
564564
});
565565

566566
it('links directly to the editor with a compound language code normalized (zh-CN → en-zhcn)', () => {
567-
const issue = { ...baseIssue, languageId: 'zh-CN', string: { text: 'Source', id: 91860, file: { id: 5842 } } };
567+
const issue = { ...baseIssue, languageId: 'zh-CN', string: { text: 'Source', id: 91860, fileId: 5842 } };
568568
const body = buildIssueBody(issue, projectId, 'my-project');
569569
expect(body).toContain('https://crowdin.com/editor/my-project/5842/en-zhcn?view=comfortable#91860');
570570
});
571571

572-
it('falls back to project page when file.id is absent', () => {
572+
it('falls back to project page when fileId is absent', () => {
573573
const issue = { ...baseIssue, languageId: 'fr', string: { text: 'Source', id: 999 } };
574574
const body = buildIssueBody(issue, projectId, 'my-project');
575575
expect(body).toContain('https://crowdin.com/project/my-project');

0 commit comments

Comments
 (0)