From eec7411e614be68db248e1f0bc103344f3b18bb2 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Tue, 15 Mar 2022 16:00:01 -0700 Subject: [PATCH] Core Data: Check for nullity in experimental fetch methods Adds a nullity check and enhances a JSDoc comment to acknowledge the nullable presence of a property in an object we test. --- .../src/fetch/__experimental-fetch-link-suggestions.js | 2 +- packages/core-data/src/fetch/__experimental-fetch-url-data.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js b/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js index fd24a6a99df6b1..2d7df356e0ff70 100644 --- a/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js +++ b/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js @@ -170,7 +170,7 @@ const fetchLinkSuggestions = async ( .slice( 0, perPage ) .map( /** - * @param {{ id: number, url:string, title?:string, subtype?: string, type?: string }} result + * @param {{ id: number, meta?: object, url:string, title?:string, subtype?: string, type?: string }} result */ ( result ) => { return { diff --git a/packages/core-data/src/fetch/__experimental-fetch-url-data.js b/packages/core-data/src/fetch/__experimental-fetch-url-data.js index 02bebeeeaac91b..effb0566691dfe 100644 --- a/packages/core-data/src/fetch/__experimental-fetch-url-data.js +++ b/packages/core-data/src/fetch/__experimental-fetch-url-data.js @@ -60,6 +60,7 @@ const fetchUrlData = async ( url, options = {} ) => { const protocol = getProtocol( url ); if ( + ! protocol || ! isValidProtocol( protocol ) || ! protocol.startsWith( 'http' ) || ! /^https?:\/\/[^\/\s]/i.test( url )