code: function formatUrl (url, query) {
    let protocol
    let index = url.indexOf('://')
    if (index !== -1) {
      protocol = url.substring(0, index)
      url = url.substring(index + 3)
    } else if (url.indexOf('//') === 0) {
      url = url.substring(2)
    }
  
    let parts = url.split('/')
    let result = (protocol ? protocol + '://' : '//') + parts.shift()
  
    let path = parts.filter(Boolean).join('/')
    let hash
    parts = path.split('#')
    if (parts.length === 2) {
      path = parts[0]
      hash = parts[1]
    }
  
    result += path ? '/' + path : ''
  
    if (query && JSON.stringify(query) !== '{}') {
      result += (url.split('?').length === 2 ? '&' : '?') + formatQuery(query)
    }
    result += hash ? '#' + hash : ''
  
    return result
  }
docs: Format given url, append query to url query string
  
  @param  {string} url
  @param  {string} query
  @return {string}