chore: mod valid id

This commit is contained in:
dsrkafuu 2022-03-13 18:31:01 +08:00
parent 624a900553
commit 22117f45f5
3 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ https://count.dsrkafuu.net/<id>?theme=<theme>&length=<length>
https://count.dsrkafuu.net/dsrkafuu:demo?theme=gelbooru
```
1. `<id>`: A string between 1-256 chars (`0-9a-zA-Z:!@#$%^&*_-`) starting with a letter (`a-zA-Z`)
1. `<id>`: Any string between 1-256 chars (`a-z0-9:.@_-` allowed)
2. `<theme>`: `asoul`, `gelbooru`, `moebooru`, `rule34` (and two other themes, default: `gelbooru`)
3. `<length>`: Number between 1-10 (default: 7) or `auto`

View File

@ -63,6 +63,7 @@ export async function get(req, event) {
status: 200,
headers: {
'Content-Type': 'image/svg+xml; charset=utf-8',
'Cache-Control': 'max-age=0, no-cache, must-revalidate', // fix github cdn cache
},
});
}

View File

@ -10,10 +10,9 @@ export function minify(str) {
/**
* @param {string} id
* @returns
*/
export function validateID(id) {
if (!/^[a-z][0-9a-z:!@#$%^&*_-]{0,255}$/i.test(id)) {
if (!/^[a-z0-9:.@_-]{1,256}$/i.test(id)) {
throw new ResError(400, 'Invalid Counter ID');
}
return id;