From ff197583be79aa1b2f2717da5483efc1dc4974b9 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Sat, 29 May 2021 15:13:40 -0400 Subject: [PATCH] If a hash is given in the URL, search for it Makes `https://torrent-paradise.ml/#ubuntu%20iso` automatically open a search for `ubuntu iso`. --- website/view.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/website/view.js b/website/view.js index 2140ff7..b421b94 100644 --- a/website/view.js +++ b/website/view.js @@ -14,4 +14,11 @@ if (searchbox != null) { searchTriggered() } } -} \ No newline at end of file +} + +// If the URL has a hash (e.g. #ubuntu iso), search for it. +if (window.location.hash) { + // `substr(1)` to trim off the leading `#`, `decodeURIComponent` to handle things like `%20` for ` `. + searchbox.value = decodeURIComponent(window.location.hash.substr(1)); + searchTriggered(); +}