How about 

   return opts.protocol + '://' + 
     (opts.userInfo) ? opts.userInfo + '@' : '' +
     opts.host + ':' + opts.port + '/' + 
     opts.path + pathDel + opts.db + '/' + path;

If you dont like that then there are a few nits that should be fixed up, if statements should be in the form

    if (opts.userInfo) { 

to be consistent, and would probably prefer a better temporary name than `ur`