storyblok
storyblok copied to clipboard
full_slug field on stories is inconsistent with trailing slashes
The feature would affect:
- [ ] app.storyblok.com (CMS - Interface)
- [x] api.storyblok.com (CMS - Content Delivery API)
- [x] mapi.storyblok.com (CMS - Management API)
- [ ] capi.storyblok.com (Commerce - API)
- [ ] Commerce - Interface
- [ ] Other
Is your feature request related to a problem? Please describe.
When fetching stories from the Content Delivery or Management API, the full_slug
field is inconsistent with trailing slashes. For folder startpages, there is a trailing slash, but for all other pages, there is not.
Describe the solution you'd like
It would be very helpful to at least have this mentioned in the docs. Updating the current API might not be realistic since it could break existing integrations, but in potential future versions of the API, I think it would be more useful to be consistent. There is already the is_startpage
field to determine whether a particular page is a startpage or not.
Describe alternatives you've considered None
Additional context None
Is there any advancement with this issue?
Is there any workarounds for this?
@IzakJackson yes, you can just check if there is a trailing slash like that and remove it. We have a function that takes the storyblok link object and looks at the different types (like url, story, asset,...) but you can just use the one for story:
if (link.linktype === "story" && link.cached_url) {
if (link.cached_url !== "/" && link.cached_url.endsWith("/")) {
return link.cached_url.slice(0, -1);
}
return link.cached_url;
}