@@ -327,7 +327,17 @@ async function createGithubIssue(
327327 if ( formData . country && formData . country in countries ) {
328328 const country = countries [ formData . country as TCountryCode ] ;
329329 const continent = continents [ country . continent ] . toLowerCase ( ) ;
330- if ( continent != null ) labels . push ( continent ) ;
330+ if ( continent != null ) labels . push ( `region/${ continent } ` ) ;
331+ }
332+
333+ if ( formData . authType !== "None - 0" ) {
334+ labels . push ( "auth required" ) ;
335+ }
336+
337+ if ( ! isValidZipUrl ( formData . feedLink ) ) {
338+ if ( ! await isValidZipDownload ( formData . feedLink ) ) {
339+ labels . push ( "invalid" ) ;
340+ }
331341 }
332342
333343 try {
@@ -441,3 +451,38 @@ export function buildGithubIssueBody(
441451 return content ;
442452}
443453/* eslint-enable */
454+
455+ /**
456+ * Parses the provided URL to check if it is a valid ZIP file URL
457+ * @param url The direct download URL provided in the feed form
458+ * @returns {boolean } Whether the URL is a valid ZIP file URL
459+ */
460+ function isValidZipUrl ( url : string | undefined | null ) : boolean {
461+ if ( ! url ) return false ;
462+ try {
463+ const parsed = new URL ( url ) ;
464+ return parsed . pathname . toLowerCase ( ) . endsWith ( ".zip" ) ;
465+ } catch {
466+ return false ;
467+ }
468+ }
469+
470+ /**
471+ * Checks if the provided URL points to a valid ZIP file by making a HEAD request
472+ * @param url The direct download URL provided in the feed form
473+ * @returns {boolean } Whether the URL downloads a valid ZIP file
474+ */
475+ async function isValidZipDownload ( url : string | undefined | null ) : Promise < boolean > {
476+ try {
477+ if ( ! url ) return false ;
478+ const response = await axios . head ( url , { maxRedirects : 2 } ) ;
479+ const contentType = response . headers [ "content-type" ] ;
480+ const contentDisposition = response . headers [ "content-disposition" ] ;
481+
482+ if ( contentType && contentType . includes ( "zip" ) ) return true ;
483+ if ( contentDisposition && contentDisposition . includes ( "zip" ) ) return true ;
484+ return false ;
485+ } catch {
486+ return false ;
487+ }
488+ }
0 commit comments