From e7f5b333dba6b106d8fedd3fa53a1480283345be Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Sat, 11 Apr 2020 18:05:35 -0400 Subject: [PATCH] Version number + improved URL file type detection. --- scripts/system/inventory/src/App.vue | 61 +++++++++++++------ .../inventory/src/assets/styles/styles.css | 7 +++ 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/scripts/system/inventory/src/App.vue b/scripts/system/inventory/src/App.vue index c89ce012cf..78c7a61c8f 100644 --- a/scripts/system/inventory/src/App.vue +++ b/scripts/system/inventory/src/App.vue @@ -44,28 +44,30 @@ > - + - - - mdi-plus - - Add Item + + + mdi-plus + + Add Item - - mdi-folder-plus - - Create Folder - + + mdi-folder-plus + + Create Folder + + +

Version {{settings.appVersion}}

@@ -1074,6 +1076,7 @@ export default { "Large", ], }, + appVersion: "1.2.1", }, darkTheme: true, drawer: false, @@ -1207,8 +1210,7 @@ export default { } }, addItem: function(name, folder, url) { - var extensionRegex = /\.[0-9a-z]+$/i; // to detect the file type based on extension in the URL. - var detectedFileType = url.match(extensionRegex); + var detectedFileType = this.detectFileType(url); var itemType; if (detectedFileType == null || detectedFileType[0] == null) { @@ -1223,6 +1225,25 @@ export default { this.addDialog.data.folder = null; this.addDialog.data.url = null; }, + detectFileType: function(url) { + // Attempt the pure regex route... + var extensionRegex = /\.[0-9a-z]+$/i; // to detect the file type based on extension in the URL. + var detectedFileType = url.match(extensionRegex); + + // If that fails, let's try the traditional URL route. + if (detectedFileType == null || detectedFileType[0] == null) { + var urlExtensionRegex = /\.[0-9a-z]+$/i; + let urlToParse = new URL(url); + + // Attempt the URL converted regex route... + detectedFileType = urlToParse.pathname.match(urlExtensionRegex); + } else if (detectedFileType == null || detectedFileType[0] == null) { // Still not working?! + // Your URL sucks! + detectedFileType = null; // We got nothin'. + } + + return detectedFileType; + }, removeItem: function(uuid) { var findItem = this.searchForItem(uuid); findItem.parentArray.splice(findItem.iteration, 1); diff --git a/scripts/system/inventory/src/assets/styles/styles.css b/scripts/system/inventory/src/assets/styles/styles.css index 5eefbb634f..ad6cc5fd0a 100644 --- a/scripts/system/inventory/src/assets/styles/styles.css +++ b/scripts/system/inventory/src/assets/styles/styles.css @@ -51,6 +51,13 @@ margin-right: 16px; } +/* Menu Slideout */ + +.appVersion { + text-align: center; + color: rgba(255, 255, 255, 0.6); +} + /* Universal */ .handle {