Hello team. Could you tell us a bit more about your use case?
Why do you need to add this suffix to the routes?
I'd think that the browser skips because it reads it as a regex
Hi @Pau, in our framework we allow our integrators to register routes with an .html prefix, based on the same principals as Path-to-RegExp.
We have clients that integrate with multiple different systems (eg; Magento, BigCommerce, Prismic, etc...) and they previously have been using .html in their paths and would like to continue in doing so, this will avoid any requirement for unnecessary redirects. We also have clients migrating to Prismic that require this.
I'd think that the browser skips because it reads it as a regex
I don't believe it is related to the browser, the routes I posted there is straight from the query made to Prismic, and you will notice the response data is without the html, it might require some special markup/escape to include the point in before the html?
We currently had to hack something into our system to get this to work, we created a path serializer, and apply it any time a path is registered with the prismic client, and then we deserialize any paths we receive from the client
But this is only a hack, and I do hope it will be fixed, or a solution will be made available.
// This is a hack to support `.html`, see https://community.prismic.io/t/routes-with-suffix/11546
export const DOT_PLACEHOLDER = "/____DOT____";
export default class PrismicPath {
/**
* Replaces all dots in the path with a placeholder.
*
* see: https://community.prismic.io/t/routes-with-suffix/11546
*
* #### Example
*
* - before: `/my/path.html`
* - after: `/my/path/____DOT____html`
*
* @param {string} path
* @returns {string}
*/
static serialize(path) {
return path.replaceAll(".", DOT_PLACEHOLDER);
}
/**
* Replaces all dot placeholders in the path with a dot.
*
* see: https://community.prismic.io/t/routes-with-suffix/11546
*
* #### Example
*
* - before: `/my/path/____DOT____html`
* - after: `/my/path.html`
*
* @param {string} path
* @returns {string}
*/
static deserialize(path) {
return path.replaceAll(DOT_PLACEHOLDER, ".");
}
}