From 76dfd08c82fd718852978e751c9f1d0d3dbf2cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Wed, 27 Mar 2019 00:14:07 +0100 Subject: [PATCH] Follow @mattwr18's review https://github.com/Human-Connection/Human-Connection/pull/248#pullrequestreview-219203465 --- .../integration/identifier/PersistentLinks.feature | 4 ++-- webapp/mixins/persistentLinks.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cypress/integration/identifier/PersistentLinks.feature b/cypress/integration/identifier/PersistentLinks.feature index 1095c6c72..5ea48ef6a 100644 --- a/cypress/integration/identifier/PersistentLinks.feature +++ b/cypress/integration/identifier/PersistentLinks.feature @@ -1,7 +1,7 @@ Feature: Persistent Links As a user - I want to click on a link with an 'href' having an unmodifiable id of a user - In order to have persistent links even if the user changes a his/her slug + I want all links to carry permanent information that identifies the linked resource + In order to have persistent links even if a part of the URL might change | | Modifiable | Referenceable | Unique | Purpose | | -- | -- | -- | -- | -- | diff --git a/webapp/mixins/persistentLinks.js b/webapp/mixins/persistentLinks.js index e902f2fbe..5cecbbdbd 100644 --- a/webapp/mixins/persistentLinks.js +++ b/webapp/mixins/persistentLinks.js @@ -14,17 +14,17 @@ export default function(options = {}) { const client = apolloProvider.defaultClient let response - let thing + let resource response = await client.query({ query: queryId, variables }) - thing = response.data[Object.keys(response.data)[0]][0] - if (thing && thing.slug === slug) return // all good - if (thing && thing.slug !== slug) { - return redirect(`/${path}/${thing.id}/${thing.slug}`) + resource = response.data[Object.keys(response.data)[0]][0] + if (resource && resource.slug === slug) return // all good + if (resource && resource.slug !== slug) { + return redirect(`/${path}/${resource.id}/${resource.slug}`) } response = await client.query({ query: querySlug, variables }) - thing = response.data[Object.keys(response.data)[0]][0] - if (thing) return redirect(`/${path}/${thing.id}/${thing.slug}`) + resource = response.data[Object.keys(response.data)[0]][0] + if (resource) return redirect(`/${path}/${resource.id}/${resource.slug}`) return error({ statusCode: 404, message }) }