Skip to content

DNR redirect rules won’t redirect to extension paths #1

Open
@lenacohen

Description

@lenacohen

DNR rules redirecting to an extension path lead to an error page: “Safari can’t open the page. The error is: “The operation couldn’t be completed. (NSURLErrorDomain error -1008.)” (NSURLErrorDomain:-1,008).”

This is an example of a redirect rule that leads to an error page instead of the extension path page:

chrome.declarativeNetRequest.updateDynamicRules({addRules: [
    {
        id: 2,
        priority: 1,
        action: {
          type: "redirect",
          redirect: {
            extensionPath: "/web_accessible_resources/test_redirect.html"
          }
        },
        condition: {
            urlFilter: "||washingtonpost.com^",
            resourceTypes: [
                "main_frame"
            ]
        }
      }
]});

The extension path is included in web_accessible_resources in the extension manifest:

      "web_accessible_resources": [{
        "resources": [
          "web_accessible_resources/test_redirect.html"
        ],

Demo Xcode extension: https://github.com/lenacohen/Safari-Test-Extensions/tree/main/dnr-extension-path-redirect (test by navigating to www.eff.org and www.washingtonpost.com)
Apple Feedback Assistant Bug Report: FB16607632
Apple Developer Forum Post
Safari version 18.3
MacOS Sequoia 15.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    DNRIssue with Safari's Declarative Net Request API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions