diff --git a/app.json b/app.json index 660134a..ed258ca 100644 --- a/app.json +++ b/app.json @@ -60,7 +60,12 @@ "value": ["48hr.email", "Crazyco", "https://crazyco.xyz"] }, "HTTP_DISPLAY_SORT": { - "description": "Sort the emails for use" + "description": "Sort the emails for use", + "value": 0 + }, + "HTTP_HIDE_OTHER": { + "description": "Hide other emails from the list besides the first", + "value": false } } } diff --git a/application/config.sample.js b/application/config.sample.js index 71d68aa..4d4bde5 100644 --- a/application/config.sample.js +++ b/application/config.sample.js @@ -28,6 +28,7 @@ const config = { // 1 sorts alphabetically, // 2 sorts alphabetically and only shuffles the first item, // 3 shuffles all + hideOther: process.env.HTTP_HIDE_OTHER || false, // Hide other emails in the list and only show first (true) or show all (false) }, } diff --git a/application/helper.js b/application/helper.js index dea2761..9e8b18d 100644 --- a/application/helper.js +++ b/application/helper.js @@ -115,6 +115,19 @@ class Helper { return array } + /** + * Hide other emails in the list and only show first (true) or show all (false) + * @param {Array} array + * @returns {Array} + */ + hideOther(array) { + if (config.http.hideOther) { + return array[0] + } else { + return array + } + } + /** * Get a domain list from config for use * @returns {Array} @@ -123,13 +136,13 @@ class Helper { getDomains() { switch (config.http.displaySort) { case 0: - return config.email.domains // No modification + return this.hideOther(config.email.domains) // No modification case 1: - return config.email.domains.sort() // Sort alphabetically + return this.hideOther(config.email.domains.sort()) // Sort alphabetically case 2: - return this.shuffleFirstItem(config.email.domains.sort()) // Sort alphabetically and shuffle first item + return this.hideOther(this.shuffleFirstItem(config.email.domains.sort())) // Sort alphabetically and shuffle first item case 3: - return this.shuffleArray(config.email.domains) // Shuffle all + return this.hideOther(this.shuffleArray(config.email.domains)) // Shuffle all } } } diff --git a/package.json b/package.json index ebb48f5..df7e6e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "48hr.email", - "version": "1.6.0", + "version": "1.6.1", "private": false, "scripts": { "start": "node --trace-warnings ./app.js",