Skip to content

Commit 7c34a23

Browse files
committed
add rule
1 parent fedadf6 commit 7c34a23

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/validator/url.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import path from 'path';
33
import { json } from 'stream/consumers';
44

55
export function url(inputUrl) {
6+
if (!inputUrl) {
7+
throw new Error('请输入 URL');
8+
}
9+
if (/\.(edu|vpn)(\/|\.|$)/.test(inputUrl)) {
10+
throw new Error('请勿提交机构代理的 URL');
11+
}
12+
if (/\.cnki\./.test(inputUrl)) {
13+
throw new Error('该 url 已通过 CNKI.js 适配。');
14+
}
15+
616
const rootDir = path.resolve(__dirname, '../../..');
717
const files = fs.readdirSync(rootDir).filter(f => f.endsWith('.js'));
818
let matched = false;
@@ -18,7 +28,8 @@ export function url(inputUrl) {
1828
matched = true;
1929
}
2030
} catch (e) {
21-
// 忽略解析错误
31+
console.error(`Error parsing JSON in ${file}:`, e);
32+
continue;
2233
}
2334
}
2435
if (matched) {

0 commit comments

Comments
 (0)