rtCamp/nginx-helper

PurgeUrl purges with trailing slash, but my permalinks have no trailing slash = no purge

Paike opened this issue · 4 comments

Paike commented

Hi,
my site does not use trailing slashes in the permalinks. In purger.php line 208 it hard codes a trailingslash to the url. So in my setup the cached pages are not purged. Full purge does not work either.

When you open the purge-url in browser with and without trailing slash, the key and path will be different.
(https://example.com/purge/page/ and https://example.com/purge/page)

When I remove trailingslashit() the pages were purged correctly.

function purgeUrl( $url, $feed = true ) {
    global $rt_wp_nginx_helper;
    $url = trailingslashit( $url );
    $this->log( "- Purging URL | " . $url );
ecoad commented

Hello. This is also an issue for our setup where we don't have trailing slashes, like @Paike

Yes same problem. Somebody told me that the problem started to emerge after this commit: 976574c

and indeed it adds a slash, however i can't figure out why there need to be an extra slash, isn't the url parsed properly?

When i figured out how i can sync my fork with the current master. I can fix it and do a pull request.

Is this issue still open? I've got the some problem.
One possibile fix could be this (sorry for not opening a PR): inside purger.php, in function purgeUrl, replace

$url = trailingslashit( $url ); 

with

$url = user_trailingslashit( $url );

I've fixed this issue in new minor version 1.9.11. I'm sorry for the delay. Please check and let me know if it's working fine.

Thanks,