Base URL of web address

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Base URL of web address

Post by MachineCode »

I need to get the base URL of a web address, ie. the "http/https" + domain of any given address. But the GetURLPart() command doesn't have an easy way to get it.

In the code below, I want the output to return: https://mail.yahoo.com

Code: Select all

Debug GetURLPart("https://mail.yahoo.com/login.css",#PB_URL_Site)
But it returns only: mail.yahoo.com (which doesn't show if it's http or https). :( So I have to resort to hacking my own:

Code: Select all

Debug GetURLPart("https://mail.yahoo.com/login.css",#PB_URL_Protocol)+"://"+GetURLPart("https://mail.yahoo.com/login.css",#PB_URL_Site)
So, a new parameter (maybe #PB_URL_Base?) would be great:

Code: Select all

Debug GetURLPart("https://mail.yahoo.com/login.css",#PB_URL_Base)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!