Plugin Directory

Changeset 3435679


Ignore:
Timestamp:
01/09/2026 07:34:05 AM (2 months ago)
Author:
scordeveloper
Message:

fix service worker end slash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • notification-button/trunk/index.php

    r3435666 r3435679  
    3737add_action('template_redirect', function() {
    3838  if (get_query_var('ntbutton_sw')) {
    39       // Prevent WordPress from adding a trailing slash to this URL
     39      // This is the key: stop WordPress from redirecting or adding slashes
     40      status_header(200);
     41      header('Content-Type: application/javascript; charset=utf-8');
     42      header('Service-Worker-Allowed: /');
     43     
     44      // Disable canonical redirect for this specific request
    4045      remove_filter('redirect_canonical', 'redirect_canonical');
    41      
    42       header('Content-Type: application/javascript; charset=utf-8');
    43       header('Service-Worker-Allowed: /');
     46
    4447      echo "importScripts('https://notificationbutton.com/assets/files/serviceWorkerContain.min.js');";
    4548      exit;
    4649  }
    47 });
     50}, 1);
    4851
    4952/**
Note: See TracChangeset for help on using the changeset viewer.