There was an error while loading. Please reload this page.
1 parent 03d556f commit 0159c45Copy full SHA for 0159c45
1 file changed
scripts/build-index.cjs
@@ -6,6 +6,7 @@
6
7
const fs = require('node:fs');
8
const path = require('node:path');
9
+const { URL } = require('node:url');
10
const { glob } = require('glob');
11
12
// Version constants
@@ -20,11 +21,17 @@ const MASTER_INDEX_VERSION = '0.1.0';
20
21
* @returns {Promise<object|null>} Repository metadata or null if not available
22
*/
23
async function fetchGitHubMetadata(repoUrl) {
- if (!repoUrl?.includes('github.com')) {
24
+ if (!repoUrl) {
25
return null;
26
}
27
28
try {
29
+ // Parse and validate the URL to prevent substring injection attacks
30
+ const url = new URL(repoUrl);
31
+ if (url.hostname !== 'github.com') {
32
+ return null;
33
+ }
34
+
35
// Extract owner/repo from URL
36
const match = new RegExp(/github\.com\/([^/]+)\/([^/]+)/).exec(repoUrl);
37
if (!match) {
0 commit comments