Skip to content

Commit f424b15

Browse files
committed
fix: gist parser
1 parent c417ab1 commit f424b15

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/utils/parser/Gist.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
import Base from './FileParser.js';
22

33
export default class Gist extends Base {
4+
#filename;
5+
46
constructor(updateUrl, downloadUrl) {
57
const url = new URL(updateUrl);
68
if (url.hostname === 'gist.github.com') {
7-
url.hostname = 'gistcdn.githack.com';
9+
const parts = url.pathname.split('/');
10+
super(
11+
`https://api.github.com/gists/${parts[2]}`,
12+
downloadUrl,
13+
);
14+
15+
this.#filename = parts.pop();
816
} else {
917
throw new Error('This parser is for github gists only');
1018
}
11-
super(`${url}`, downloadUrl);
19+
}
20+
21+
parseData({ files = {} } = {}) {
22+
const file = files[this.#filename];
23+
return super.parseData(file?.content);
1224
}
1325
}

0 commit comments

Comments
 (0)