From ce76e280983fb2d92d5965aa760e828d85c95918 Mon Sep 17 00:00:00 2001 From: AKharytonchyk Date: Wed, 5 Aug 2020 17:47:42 +0300 Subject: [PATCH] fix: support url with port --- src/get-critical-css.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/get-critical-css.js b/src/get-critical-css.js index b15c9af..ce9b44c 100644 --- a/src/get-critical-css.js +++ b/src/get-critical-css.js @@ -22,15 +22,11 @@ const args = yargs .demandOption(['url', 'output']).argv; function getFileName(props) { - const { url, width, height } = props; - let fileName = url - .replace(/http?(s):\/\//i, '') - .replace(/\?.+/, '') - .replace(/\//g, '.'); + const { url } = props; + const fileName = url.replace(/https?:\/\/|\/$/ig,'').replace(/:|\//gi, '_'); - if (width && height) fileName = ''.concat(fileName, '.', width, 'x', height); - - return fileName.concat('.css').replace(/\.\./g, '.'); + console.log(fileName.concat('.css')); + return fileName.concat('.css'); };