How can I add .locahost
to the list of TLDs that Safari will load — instead of searching — without supplying a protocol? Alternatively (or perhaps additionally), how do I get Safari to stop removing the http://
protocol from the URL?
I've been using project.localhost
to handle local development for a while, now that .dev
is no longer a viable development TLD. But I'm getting frustrated with Safari's default behavior. What I'd like to do is prevent Safari from submitting the domain name to the search engine.
Desired:
project.localhost
into address barhttp://project.localhost
I would be satisfied with Safari not removing the http://
in the address bar, but I can't find a way to do that, either.
What actually happens:
project.localhost
into address barproject.localhost
to Duck Duck GoOr, after I've loaded http://project.localhost
and then try to add something after the current URL:
project.localhost
/test.html
to endproject.localhost/test.html
to Duck Duck GoIf you just type the trailing '/', then the search will be bypassed.
Turns out that the Safari extension might be a long term solution. At this moment, I can't manage the developer membership cost. But here's the working code, for Future Me and anyone else looking into this.
In the extension's global page <script>
:
(function() {
safari.application.addEventListener("beforeSearch", function(event) {
if (event.query.split("/")[0].split(".").pop() == "localhost") {
event.preventDefault();
safari.application.activeBrowserWindow.activeTab.url = "http://" + event.query;
}
}, true);
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With