From eba6837540f402e5c39023fe5eda0615f5ec931a Mon Sep 17 00:00:00 2001 From: crosshj Date: Thu, 25 Aug 2022 14:43:51 -0400 Subject: [PATCH] v0.0.10, defensive checks --- package.json | 2 +- src/utils.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e2d411b..2760893 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fiug/layout", - "version": "0.0.9", + "version": "0.0.10", "description": "page layout for browser applications", "main": "dist/layout.js", "exports": { diff --git a/src/utils.js b/src/utils.js index 3450faf..6e5ed50 100644 --- a/src/utils.js +++ b/src/utils.js @@ -15,7 +15,7 @@ export const randomId = (prefix="_") => prefix + Math.random().toString(16).replace('0.',''); -export function UrlParams(url){ +export function UrlParams(url=""){ const paramsString = url.includes('?') ? url.split('?').pop() : ""; @@ -34,9 +34,10 @@ export function addParams(url, toAdd){ return url.split("?").shift() + "?" + newParams.toString(); } -export const getFilename = (target) => { +export const getFilename = (target="") => { const params = UrlParams(target); const path = params.get('file'); + if(!path) return ""; const filename = path.split("/").pop(); return filename; };