From 2123590394830a182a5b2a0b7a445be8aad90bca Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Wed, 30 Sep 2020 23:22:27 +0200 Subject: [PATCH 1/2] update from dev (#11) * first attempt at using a netlify function for link checking * trigger netlify deploy? * fix prebuild functions build * move functions build to postbuild - the dist folder doesn't exitst before the build is finished * add error handling to netlify function * try not parsing json * improved error messages * check if JSON.parse throws the lamba error * more error handling * lamba issues seemingly fixed * convert bool to string before calling callback * added virus scan button - also changed highlight effect * added loading indicator for infinite scroll * retrieve file size from lamba function * make lambda fetch timeout * added AbortController Node implementation * support handling gateway errors as dead links * include tips * handle missing size * fix 404s with driveindex.ga * debug * fixed resolve function * Split views (#2) * split home/hero and search into separate views - removed unneeded state variables - reordered dependencies to prevent errors - improved store defaults - added netlify redirect rules for SPA * url-based pagination - load results starting from the page in the url - correctly indicate the current page out of all results * fix incorrect page number after searching again * change document title with pagination * small fixes * fix relative link * fix pagination issues - also include the sponsor button * stop cog spinner * small improvements - fixed the title on the index page - open links in a new tab by default (this closes #3) - encode links before copying them to the clipboard (this closes #4) * Typo: corresponing (#9) fixed a typo * fix alive check for driveindex.ga * more logging * reduce number of lambda calls * fix query not being escaped - also deploy new lambda function * use old lambda function * re-integrate driveindex.ga workaround * fix router issues when searching for a new query Co-authored-by: M*C*O --- public/netlify-functions/checkLinkAlive.js | 22 +++++++++++++++++----- src/assets/js/api.js | 2 +- src/components/LinkRow.vue | 6 +++--- src/views/Home.vue | 4 ++++ src/views/Search.vue | 10 ++++++++-- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/public/netlify-functions/checkLinkAlive.js b/public/netlify-functions/checkLinkAlive.js index 8178cfc..4ae0e81 100644 --- a/public/netlify-functions/checkLinkAlive.js +++ b/public/netlify-functions/checkLinkAlive.js @@ -12,9 +12,19 @@ const fetchTimeout = (url, ms, options = {}) => { function resolveLink(url) { let resolvedUrl = url; - resolvedUrl = resolvedUrl.replace(`driveindex.ga/`, `hashhackers.com/`); + let resolvedHeaders = {}; + + if (url.includes(`driveindex.ga/`)) { + resolvedUrl = resolvedUrl.replace(`driveindex.ga/`, `hashhackers.com/`); + resolvedHeaders = { + 'referer': `hashhackers.com`, + } + } - return resolvedUrl; + return { + url: resolvedUrl, + headers: resolvedHeaders, + }; } @@ -44,10 +54,11 @@ exports.handler = function(event, context, callback) { }) } - let urlToCheck = resolveLink(parsedBody.url); + let resolvedUrlData = resolveLink(parsedBody.url); - fetchTimeout(urlToCheck, 9500, { + fetchTimeout(resolvedUrlData.url, 9500, { method: `HEAD`, + headers: resolvedUrlData.headers, }).then(res => { return callback(null, { @@ -55,7 +66,8 @@ exports.handler = function(event, context, callback) { body: JSON.stringify({ isAlive: res.ok, sizeInBytes: res.headers.get(`Content-Length`), - checkedUrl: urlToCheck, + checkedUrl: resolvedUrlData.url, + headers: resolvedUrlData.headers, }) }) diff --git a/src/assets/js/api.js b/src/assets/js/api.js index fd59d29..df55fc7 100644 --- a/src/assets/js/api.js +++ b/src/assets/js/api.js @@ -46,7 +46,7 @@ export default class API { search(query, offset = 0, limit = 20) { return new Promise((resolve, reject) => { - fetch(this.apiEndpoint + `/search?q=${query}&offset=${offset}&limit=${limit}&attributesToHighlight=url`, { + fetch(this.apiEndpoint + `/search?q=${encodeURIComponent(query)}&offset=${encodeURIComponent(offset)}&limit=${encodeURIComponent(limit)}&attributesToHighlight=url`, { mode: 'cors', method: 'GET', headers: { diff --git a/src/components/LinkRow.vue b/src/components/LinkRow.vue index 928e966..8b1af75 100644 --- a/src/components/LinkRow.vue +++ b/src/components/LinkRow.vue @@ -18,6 +18,8 @@ > diff --git a/src/views/Home.vue b/src/views/Home.vue index f10a03f..a03da78 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -3,6 +3,10 @@ class="w-full h-full p-4" > + +
diff --git a/src/views/Search.vue b/src/views/Search.vue index 7daa397..3e9a811 100644 --- a/src/views/Search.vue +++ b/src/views/Search.vue @@ -104,7 +104,7 @@ export default { resultListBottomText: ``, activeTipIndex: 0, tips: [ - `You can click on subpaths to jump to the corresponing folder!`, + `You can click on subpaths to jump to the corresponding folder!`, `Strike-through'd links are most likely dead!`, `You can see the amount of pages on the left side of the links!`, `You can click the middle mouse button (scroll wheel) to open links in a new tab!` @@ -146,9 +146,15 @@ export default { this.lowestPage = page; this.highestPage = page; + if (location.pathname != `/search/${query}`) { + this.$router.push({ + path: `/search/${query}`, + }) + } + if (this.$route.query.p && Number(this.$route.query.p) != this.highestPage) { this.$router.push({ - path: this.$router.path, + path: location.pathname, query: { p: this.highestPage, } From d90c61250871381d5d14d45a8752832d0adc7bd0 Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Thu, 1 Oct 2020 14:56:08 +0200 Subject: [PATCH 2/2] update from dev (#12) * first attempt at using a netlify function for link checking * trigger netlify deploy? * fix prebuild functions build * move functions build to postbuild - the dist folder doesn't exitst before the build is finished * add error handling to netlify function * try not parsing json * improved error messages * check if JSON.parse throws the lamba error * more error handling * lamba issues seemingly fixed * convert bool to string before calling callback * added virus scan button - also changed highlight effect * added loading indicator for infinite scroll * retrieve file size from lamba function * make lambda fetch timeout * added AbortController Node implementation * support handling gateway errors as dead links * include tips * handle missing size * fix 404s with driveindex.ga * debug * fixed resolve function * Split views (#2) * split home/hero and search into separate views - removed unneeded state variables - reordered dependencies to prevent errors - improved store defaults - added netlify redirect rules for SPA * url-based pagination - load results starting from the page in the url - correctly indicate the current page out of all results * fix incorrect page number after searching again * change document title with pagination * small fixes * fix relative link * fix pagination issues - also include the sponsor button * stop cog spinner * small improvements - fixed the title on the index page - open links in a new tab by default (this closes #3) - encode links before copying them to the clipboard (this closes #4) * Typo: corresponing (#9) fixed a typo * fix alive check for driveindex.ga * more logging * reduce number of lambda calls * fix query not being escaped - also deploy new lambda function * use old lambda function * re-integrate driveindex.ga workaround * fix router issues when searching for a new query * UI enhancements - add a 'share' button using the web share API - use icons instead of text for link actions (copy, share, scan) - add a notice when using the search site in portrait mode * design changes - moved 'powered by' section to the bottom of the page - included more links in 'powered by'-section - improved mobile layout * make 'powered by' links open in a new tab Co-authored-by: M*C*O --- src/App.vue | 2 +- src/components/LinkRow.vue | 112 +++++++++++++++-- src/components/SearchField.vue | 7 +- src/views/Home.vue | 217 +++++++++++++++++++++++---------- src/views/Search.vue | 24 +++- 5 files changed, 284 insertions(+), 78 deletions(-) diff --git a/src/App.vue b/src/App.vue index 84af9ee..bc1e60d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@