Skip to content

Commit 0ac85dd

Browse files
committed
fix: use URL's last endpoint to get commit ref
1 parent 0baf989 commit 0ac85dd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

404.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
</head>
55

66
<script>
7+
const ref = location.pathname.split('/').pop()
78
/* https://docs.github.com/en/rest/commits/commits#get-a-commit
8-
the `location.pathname` can be:
9+
the `${ref}` can be:
910
- the prefix(at least 4 characters) of a commit SHA-1 hash
1011
- the tag name of a commit */
11-
const url = `https://api.github.com/repos/liqwang/link/commits${location.pathname}`
12+
const url = `https://api.github.com/repos/liqwang/link/commits${ref}`
1213

1314
fetch(url)
1415
.then(response => {

0 commit comments

Comments
 (0)