File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,35 @@ exports[`
334334}
335335` ;
336336
337+ exports [`
338+ feed(url: "not-a-url") { title }
339+ 1` ] = `
340+ {
341+ " data" : {
342+ " feed" : null ,
343+ },
344+ " errors" : [
345+ {
346+ " extensions" : {
347+ " code" : " invalid-url" ,
348+ " message" : " Invalid url" ,
349+ " type" : " InvalidUrlError" ,
350+ },
351+ " locations" : [
352+ {
353+ " column" : 3 ,
354+ " line" : 2 ,
355+ },
356+ ],
357+ " message" : " Invalid url" ,
358+ " path" : [
359+ " feed" ,
360+ ],
361+ },
362+ ],
363+ }
364+ ` ;
365+
337366exports [`
338367 findFeed(url: "https://non--------existing-domain.com") { link }
339368 1` ] = `
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ testGraphqlApi`
5151 feed(url: "https://non--------existing-domain.com") { title }
5252` ;
5353
54+ testGraphqlApi `
55+ feed(url: "not-a-url") { title }
56+ ` ;
57+
5458testGraphqlApi `
5559 feed(url: "${ url } ", startTime: "2020-01-01", endTime: "2020-10-31") {
5660 items { title }
Original file line number Diff line number Diff line change 1+ import isUrl from "is-url" ;
12import {
23 BaseError ,
34 EmptyParserOutputError ,
5+ InvalidUrlError ,
46 NotAFeedError ,
57 ParserError ,
68} from "../errors.js" ;
@@ -53,6 +55,9 @@ export async function parseFromQuery({
5355 endTime ?: string ;
5456 startTime ?: string ;
5557} ) : Promise < ParserResponse > {
58+ if ( ! isUrl ( url ) ) {
59+ throw new InvalidUrlError ( url ) ;
60+ }
5661 const response = await request ( url ) ;
5762
5863 const contentType =
You can’t perform that action at this time.
0 commit comments