mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Follow @mattwr18's review
https://github.com/Human-Connection/Human-Connection/pull/248#pullrequestreview-219203465
This commit is contained in:
parent
88ac0601f7
commit
76dfd08c82
@ -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 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
|
||||
@ -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 })
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user