Skip to content

Commit bd5ca9a

Browse files
fix(docs): URL-encode owner/repo before hitting the GitHub API in star-history (#534)
fetchStarTimestamps() interpolated owner/repo straight into the stargazers request URL with no encoding. parseRepos() takes raw user-typed text, so a repo string containing a space, &, #, or other URL-significant character (a stray character when pasting, or a free-form "owner/repo name" typo) silently broke the query string or truncated the path instead of producing a clean request or a readable 404. Wrap both segments in encodeURIComponent(). Verified normal repo names (e.g. cobusgreyling/loop-engineering) produce an identical URL, and a name with a space and an ampersand now encodes cleanly instead of corrupting the query string. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent bce5933 commit bd5ca9a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/star-history.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ <h2 id="token-title">GitHub access token</h2>
234234
const timestamps = [];
235235
let page = 1;
236236
while (true) {
237-
const url = `https://api.github.com/repos/${owner}/${repo}/stargazers?per_page=100&page=${page}`;
237+
const url = `https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/stargazers?per_page=100&page=${page}`;
238238
const res = await fetch(url, {
239239
headers: {
240240
Accept: 'application/vnd.github.v3.star+json',

0 commit comments

Comments
 (0)