Skip to content

If a page only has one match, then you can end up with duplicate URLs #84

@sean-dunwoody

Description

@sean-dunwoody

Describe the bug
Duplicate URLs can be created when the API call to WordPress only matches one item.

To Reproduce

  1. Create a page in WordPress that sits on the second level of the site, e.g.

/about-us/the-team

  1. View this page in the frontend to see that it works.
  2. Manipuate the URL so that about-us changes to something else, e.g.

/any-value-in-here/the-team

  1. Page should be returned. This means the same content can be accessed on multiple duplicate (and incorrect URLs)

Expected behavior
The page should only be returned when the exact request URL matches the full URL in WordPress

Additional context
This only seems to happen when the WordPress API returns exactly one match. This is the endpoint in question:

/wp-json/wp/v2/pages?slug=/page-url-here/

This only requests the final segement of the URL, e.g. in the above example:

/about-us/the-team

The query would be:

/wp-json/wp/v2/pages?slug=/the-team/

If this API response returns more than one match, then this error doesn't occur.

I think this is related to the following recent changes:

https://github.com/strata/frontend/pull/83/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions