Thank you, @nixoloco. Your solution worked for me. This has been bugging me for months and this fixed it! I am not an extension developer but I have Xcode 13 installed. I don’t know how my Launch Services database got messed up.
Note: add a space before lsregister:
PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH" lsregister -f /Applications/Safari.app