From e0296e7fb3fd6e9ae8a394da8727f49038871ffc Mon Sep 17 00:00:00 2001 From: chlorophyllenvy Date: Tue, 22 May 2018 17:20:42 -0400 Subject: [PATCH] Update gulpfile to ensure URL not tainted with key API key was being placed before URL and creating an incorrect URL structure https://www.googleapis.com/pagespeedonline/v2/runPagespeed?filter_third_party_resources=false&locale=en_GB&screenshot=false&strategy=mobile&key=TheKeyValueshttps%3A%2F%2Fdomain.com%2Findex.php --- gulpfile.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3339a04..226d983 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -72,10 +72,11 @@ function speedtest() { results = { oldresults: { mobile: null, desktop: null }, newresults: {} }, errorOccured = false, - finishedCount = 0; - if (settings.googleAPIKey) { - googleAPIURL += '&key='+settings.googleAPIKey; - } + finishedCount = 0, + key = settings.googleAPIKey ? '&key='+settings.googleAPIKey+'&url=' : '&url='; + // Configure with key + googleAPIURL += key; + if (fs.existsSync(logFile)) { results = JSON.parse(fs.readFileSync(logFile, { encoding: 'Utf-8' })); @@ -253,4 +254,4 @@ function GruntTasks (grunt) { grunt.loadNpmTasks("grunt-then"); grunt.registerTask('default', ['devperf']); -} \ No newline at end of file +}