Skip to content

Commit 5d9bf83

Browse files
author
Ben Chang
committed
encode the search query
1 parent 5fba9fd commit 5d9bf83

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

web_src/js/components/RepoContributors.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export default {
8181
xAxisEnd: null,
8282
xAxisMin: null,
8383
xAxisMax: null,
84-
searchQuery: '',
8584
}),
8685
mounted() {
8786
this.fetchGraphData();
@@ -98,16 +97,22 @@ export default {
9897
methods: {
9998
sortContributors() {
10099
const contributors = this.filterContributorWeeksByDateRange();
101-
const min = dayjs(this.xAxisMin).format('YYYY-MM-DD');
102-
const max = dayjs(this.xAxisMax).format('YYYY-MM-DD');
103-
this.searchQuery = `${this.repoLink}/commits/branch/${this.repoBranch}/search?q=after:${min}, before:${max}, author:`;
104100
const criteria = `total_${this.type}`;
105101
this.sortedContributors = Object.values(contributors)
106102
.filter((contributor) => contributor[criteria] !== 0)
107103
.sort((a, b) => a[criteria] > b[criteria] ? -1 : a[criteria] === b[criteria] ? 0 : 1)
108104
.slice(0, 100);
109105
},
110106
107+
getContributorSearchQuery(contributorEmail: string) {
108+
const min = dayjs(this.xAxisMin).format('YYYY-MM-DD');
109+
const max = dayjs(this.xAxisMax).format('YYYY-MM-DD');
110+
const params = new URLSearchParams({
111+
'q': `after:${min}, before:${max}, author:${contributorEmail}`,
112+
});
113+
return `${this.repoLink}/commits/branch/${this.repoBranch}/search?${params.toString()}`;
114+
},
115+
111116
async fetchGraphData() {
112117
this.isLoading = true;
113118
try {
@@ -398,7 +403,7 @@ export default {
398403
</h4>
399404
<p class="tw-text-12 tw-flex tw-gap-1">
400405
<strong v-if="contributor.total_commits">
401-
<a class="silenced" :href="searchQuery + contributor.email">
406+
<a class="silenced" :href="getContributorSearchQuery(contributor.email)">
402407
{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}
403408
</a>
404409
</strong>

0 commit comments

Comments
 (0)