fixed space char issue, created mainURL var

fixed space character issue when parsing direct-URLs and made a single
variable for main-URL instead of having it at multiple places.