mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-02-06 09:55:50 +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
|
Feature: Persistent Links
|
||||||
As a user
|
As a user
|
||||||
I want to click on a link with an 'href' having an unmodifiable id of a user
|
I want all links to carry permanent information that identifies the linked resource
|
||||||
In order to have persistent links even if the user changes a his/her slug
|
In order to have persistent links even if a part of the URL might change
|
||||||
|
|
||||||
| | Modifiable | Referenceable | Unique | Purpose |
|
| | Modifiable | Referenceable | Unique | Purpose |
|
||||||
| -- | -- | -- | -- | -- |
|
| -- | -- | -- | -- | -- |
|
||||||
|
|||||||
@ -14,17 +14,17 @@ export default function(options = {}) {
|
|||||||
const client = apolloProvider.defaultClient
|
const client = apolloProvider.defaultClient
|
||||||
|
|
||||||
let response
|
let response
|
||||||
let thing
|
let resource
|
||||||
response = await client.query({ query: queryId, variables })
|
response = await client.query({ query: queryId, variables })
|
||||||
thing = response.data[Object.keys(response.data)[0]][0]
|
resource = response.data[Object.keys(response.data)[0]][0]
|
||||||
if (thing && thing.slug === slug) return // all good
|
if (resource && resource.slug === slug) return // all good
|
||||||
if (thing && thing.slug !== slug) {
|
if (resource && resource.slug !== slug) {
|
||||||
return redirect(`/${path}/${thing.id}/${thing.slug}`)
|
return redirect(`/${path}/${resource.id}/${resource.slug}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
response = await client.query({ query: querySlug, variables })
|
response = await client.query({ query: querySlug, variables })
|
||||||
thing = response.data[Object.keys(response.data)[0]][0]
|
resource = response.data[Object.keys(response.data)[0]][0]
|
||||||
if (thing) return redirect(`/${path}/${thing.id}/${thing.slug}`)
|
if (resource) return redirect(`/${path}/${resource.id}/${resource.slug}`)
|
||||||
|
|
||||||
return error({ statusCode: 404, message })
|
return error({ statusCode: 404, message })
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user