Skip to content

Commit 07c51ba

Browse files
committed
Bugfix - fix broken ember-data GitHub URLS
If the file has packages already in the path, make sure we don't add duplicate packages via the mainDir function. Fixes an issue with ember data URLS having an incorrect 'packages/packages' in the GitHub source URL Example problem was https://api.emberjs.com/ember-data/4.10/classes/RecordArray
1 parent a47e182 commit 07c51ba

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

app/helpers/github-link.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
import { helper } from '@ember/component/helper';
22
import githubMap, { mainDir } from '../utils/github-map';
33

4+
/**
5+
* https://github.com/emberjs/data/tree/v4.10.0/packages/packages/
6+
* store/addon/-private/record-arrays/identifier-array.ts#L118
7+
*
8+
* File: ../packages/store/addon/-private/record-arrays/identifier-array.ts
9+
*/
410
export function githubLink([project, version, file, line], { isEdit = false }) {
511
if (isEdit) {
612
return `https://github.com/${githubMap[project]}/edit/release${mainDir(
713
project,
814
version
915
)}${file}#L${line}`;
1016
}
11-
return `https://github.com/${githubMap[project]}/tree/v${version}${mainDir(
12-
project,
13-
version
14-
)}${file}#L${line}`;
17+
18+
// If the file has packages already in the path, make sure we don't
19+
// add duplicate packages via the mainDir function.
20+
// Fixes an issue with ember data URLS having an incorrect
21+
// 'packages/packages' in the GitHub source URL
22+
const fixedFile = file.replace('../packages/', '../');
23+
24+
const result = `https://github.com/${
25+
githubMap[project]
26+
}/tree/v${version}${mainDir(project, version)}${fixedFile}#L${line}`;
27+
return result;
1528
}
1629

1730
export default helper(githubLink);

0 commit comments

Comments
 (0)