File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,33 @@ exports[`
363363}
364364` ;
365365
366+ exports [`
367+ findFeed(url: "ftp://example.com") { link }
368+ 1` ] = `
369+ {
370+ " data" : null ,
371+ " errors" : [
372+ {
373+ " extensions" : {
374+ " code" : " invalid-url" ,
375+ " message" : " Invalid url" ,
376+ " type" : " InvalidUrlError" ,
377+ },
378+ " locations" : [
379+ {
380+ " column" : 3 ,
381+ " line" : 2 ,
382+ },
383+ ],
384+ " message" : " Invalid url" ,
385+ " path" : [
386+ " findFeed" ,
387+ ],
388+ },
389+ ],
390+ }
391+ ` ;
392+
366393exports [`
367394 findFeed(url: "https://non--------existing-domain.com") { link }
368395 1` ] = `
Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ testGraphqlApi`
6969 findFeed(url: "not-a-url") { link }
7070` ;
7171
72+ testGraphqlApi `
73+ findFeed(url: "ftp://example.com") { link }
74+ ` ;
75+
7276testGraphqlApi `
7377 findFeed(url: "https://non--------existing-domain.com") { link }
7478` ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export async function parseFromQuery({
5555 endTime ?: string ;
5656 startTime ?: string ;
5757} ) : Promise < ParserResponse > {
58- if ( ! isUrl ( url ) ) {
58+ if ( ! / ^ h t t p s ? / . test ( url ) || ! isUrl ( url ) ) {
5959 throw new InvalidUrlError ( url ) ;
6060 }
6161 const response = await request ( url ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { CheerioAPI } from "cheerio";
33import type { Element , Node } from "domhandler" ;
44import normalizeUrl from "normalize-url" ;
55
6- import { BaseError , InvalidUrlError } from "../errors.js" ;
6+ import { InvalidUrlError } from "../errors.js" ;
77import { logger } from "../logger.js" ;
88import request from "../request.js" ;
99import { parseFromQuery , parseFromString } from "./feed.js" ;
@@ -90,18 +90,20 @@ async function findRssFeedsInDom(
9090export async function findFeed ( {
9191 url,
9292 normalize = false ,
93+ withGuessFallback = false ,
9394} : {
9495 url : string ;
9596 normalize ?: boolean ;
97+ withGuessFallback ?: boolean ;
9698} ) : Promise < FindFeedResponse [ ] > {
97- if ( ! isUrl ( url ) ) {
99+ if ( ! / ^ h t t p s ? / . test ( url ) || ! isUrl ( url ) ) {
98100 throw new InvalidUrlError ( url ) ;
99101 }
100102
101103 const normalizedUrl = normalize ? url : normalizeUrl ( url , normalizeOptions ) ;
102104
103105 if ( ! normalizedUrl ) {
104- throw new BaseError ( "Empty url is not allowed" , "missing-url" ) ;
106+ throw new InvalidUrlError ( url ) ;
105107 }
106108
107109 const response = await request ( normalizedUrl ) ;
You can’t perform that action at this time.
0 commit comments