Why tabs.update doesn't work if url filters are added?

I am trying to make a safari extension that will redirect some specific URLs to some other URLs.

background.js

function redirect(event) {
    console.log("called ")
    const redirectURL = "https://apple.com/"
    chrome.tabs.update(event.tabId, { url: redirectURL })
}

// This works and redirects everything to apple.com
chrome.webNavigation.onBeforeNavigate.addListener(redirect)

/*
tabs.update doesn't work as soon as URL filter is added, but the same piece of code works in a chrome extension but not in safari

OnBeforeNavigate is called on accessing girlcodeit.com as the console statement is printed on accessing girlcodeit.com but tab is not updated.
*/

chrome.webNavigation.onBeforeNavigate.addListener(redirect, {
    url: [
        { urlMatches: "https://girlcodeit.com/*" },
        { urlMatches: "http://girlcodeit.com/*" }
    ]
})

manifest.json

    "manifest_version": 2,
    "name": "",
    "description": "",
    "version": "1.0",
    "background": {
        "scripts": [
            "background.js"
        ]
    },
    "permissions": [
        "webNavigation",
        "tabs"
    ]
}

How do I redirect only specific URLs and not all URLs or is there something wrong with the above piece of code, but because it works on chrome, it could be a bug in safari?

Why tabs.update doesn't work if url filters are added?
 
 
Q