AgregoreWeb / agregore-browser

A minimal browser for the distributed web (Desktop version)
https://www.youtube.com/watch?v=TnYKvOQB0ts&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=14
GNU Affero General Public License v3.0
715 stars 66 forks source link

Prepend http:// when localhost is in omnibox #189

Closed av8ta closed 1 year ago

av8ta commented 2 years ago

To have the same behaviour as other browsers.

RangerMauve commented 2 years ago

Oo, that's a great idea!

RangerMauve commented 2 years ago

steps to take:

https://github.com/AgregoreWeb/agregore-browser/blob/master/app/ui/omni-box.js#L65

https://github.com/AgregoreWeb/agregore-browser/blob/master/app/ui/omni-box.js#L195

Inside the two blocks that use looksLikeDomain add another check for isLocalhost() which could be implemented just after this line

function isLocalhost(string) {
  return string.startsWith('localhost')
}

Then have a makeHttp() function around this line which could look like

function makeHttp(queryy) {
  return `http://${query}`
}

So the code would look something like;

if(looksLikeDomain(whatever)) {
  if(isLocalhost(whatever)) {
     makeHttp(whatever)
  } else {
     makeHttps(whatever)
  }
}
RangerMauve commented 1 year ago

Fixed in #199 currently building the release for 1.4.1

av8ta commented 1 year ago

Thanks @techie177 :)

av8ta commented 1 year ago

The code to prepend http isn't running. I'll have a look at it.

techie177 commented 1 year ago

Oh? I'm surprised it seemed to be working just fine when I had tested it directly in the latest version of the browser at the time

av8ta commented 1 year ago

That's weird, it wasn't working for me. Added this part so that it builds the url and shows "Go to http://localhost..." https://github.com/AgregoreWeb/agregore-browser/blob/ce09498da3c12413fc7b57144eab10ead921a6b2/app/ui/omni-box.js#L196

Also changed the check to a regex because the startsWith check worked fine for localhost but also for localhostanything. Now it must be localhost for port 80 or localhost:<some digits>

techie177 commented 1 year ago

I still need to get the latest version of the browser installed but I just tried it now and it works just fine on version 1.4.0 . I went to duckduckgo's home page 2022-07-22_22-23

av8ta commented 1 year ago

When you type localhost the idea is it goes to http://localhost instead of searching duckduckgo

av8ta commented 1 year ago

I still need to get the latest version of the browser installed but I just tried it now and it works just fine on version 1.4.0 . I went to duckduckgo's home page 2022-07-22_22-23

Yes, that's correct if you want to search, but the feature of #189 is "Prepend http:// when localhost is in omnibox" :rofl:

techie177 commented 1 year ago

When you type localhost the idea is it goes to http://localhost instead of searching duckduckgo

oh I see what you mean, yeah that does make sense

av8ta commented 1 year ago

Yep, it's all good now :)