The global $base_url variable begins with http:///.

For example, the following command will display "http:///example.com":

drush eval "global \$base_url; drush_print\(\$base_url\);"

CommentFileSizeAuthor
#5 drush_base_url_591814.patch670 bytessrhaber
#4 591814.patch1.11 KBowen barton

Comments

srhaber’s picture

I should mention that I run Drush on a multisite environment, so I usually pass in the -l option. I see the three slashes when I run this command:

drush -l example.com eval "global \$base_url; drush_print\(\$base_url\);"

This displays http:///example.com.

However, I just saw Moshe's comment about always including http:// in the -l option here: http://drupal.org/node/523194#comment-2098778

Sure enough, when I use this below command then $base_url displays correctly:

drush -l http://example.com eval "global \$base_url; drush_print\(\$base_url\);"

This displays http://example.com.

srhaber’s picture

Category: bug » feature

I added some logic to my drushrc.php to work around this. However, I feel drush should be able to support taking host names without the http:// prefix. Changing this from a bug report to feature request.

moshe weitzman’s picture

It doesn't allow that, because $base_url in drupal doesn't allow that. it might be more helpful to rename --uri to --base-url. Comments?

owen barton’s picture

Status: Active » Needs review
StatusFileSize
new1.11 KB

I don't have a problem with allowing the "http://" to be omitted, I don't think forcing it to be there adds any value, and we are already adding one implicitly for URIs guessed from the site directory name.

What about the attached patch? You can still pass http:// if you prefer (or https:// or any other protocol if working on something really weird!).

srhaber’s picture

StatusFileSize
new670 bytes

I agree the "http://" should be added by default if it's not included. Attached is my patch which has same effect as #4.

We should probably rename this thread to "Make http:// prefix optional for --url option"?

moshe weitzman’s picture

Title: Global $base_url variable has 3 slashes » Make http:// prefix optional for --url option"
Status: Needs review » Fixed

Committed #5. Thanks all.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.