豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 1c22264

Browse files
authored
fix(ng-dev): properly encode URLs for GitHub queries in caretaker check (#766)
* fix(ng-dev): properly encode URLs for GitHub queries in caretaker check The URLs constructed by `caretaker/github.ts` were incorrectly escaped and ended up e.g. not escaping a colon in URLs. * fixup! fix(ng-dev): properly encode URLs for GitHub queries in caretaker check Fix old invalid test and add additional query test
1 parent bc61791 commit 1c22264

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

ng-dev/caretaker/check/github.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,34 @@ describe('GithubQueriesModule', () => {
5454
issueCount: 1,
5555
nodes: [{url: 'http://github.com/owner/name/issue/1'}],
5656
},
57+
'query_with_colon': {
58+
issueCount: 0,
59+
nodes: [],
60+
},
5761
});
5862
const module = new GithubQueriesModule(git, {
5963
...mockNgDevConfig,
60-
caretaker: {githubQueries: [{name: 'key name with spaces', query: 'issue: yes'}]},
64+
caretaker: {
65+
githubQueries: [
66+
{name: 'key name with spaces', query: 'issue: yes'},
67+
{name: 'query_with_colon', query: 'is:milestone'},
68+
],
69+
},
6170
});
6271

6372
expect(await module.data).toEqual([
6473
{
6574
queryName: 'key name with spaces',
6675
count: 1,
67-
queryUrl: 'https://github.com/owner/name/issues?q=issue:%20yes',
76+
queryUrl: 'https://github.com/owner/name/issues?q=issue%3A%20yes',
6877
matchedUrls: ['http://github.com/owner/name/issue/1'],
6978
},
79+
{
80+
queryName: 'query_with_colon',
81+
count: 0,
82+
queryUrl: 'https://github.com/owner/name/issues?q=is%3Amilestone',
83+
matchedUrls: [],
84+
},
7085
]);
7186
});
7287
});

ng-dev/caretaker/check/github.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ export class GithubQueriesModule extends BaseModule<GithubQueryResults | void> {
6666
const {owner, name: repo} = this.git.remoteConfig;
6767

6868
return results.map((result, i) => {
69+
const query = queries[i];
70+
const queryURLParam = encodeURIComponent(query.query);
71+
6972
return {
70-
queryName: queries[i].name,
73+
queryName: query.name,
7174
count: result.issueCount,
72-
queryUrl: encodeURI(`https://github.com/${owner}/${repo}/issues?q=${queries[i].query}`),
75+
queryUrl: `https://github.com/${owner}/${repo}/issues?q=${queryURLParam}`,
7376
matchedUrls: result.nodes.map((node) => node.url),
7477
};
7578
});

0 commit comments

Comments
 (0)