/**
  * Method to build the merged URL
  *
  * @param string $type
  * @param array  $list
  *
  * @return string
  */
 private function buildMergeUrl($type, $list = array())
 {
     // Append the list as arguments to the URL
     $files = array();
     foreach ($list as $file) {
         $files[] = $file['file'];
     }
     $app = JFactory::getApplication()->getClientId();
     $version = $this->params->get('version', 1);
     $files = ScriptMergeHelper::encodeList($files);
     $url = 'index.php?option=com_scriptmerge&format=raw&tmpl=component';
     $url .= '&type=' . $type . '&app=' . $app . '&version=' . $version . '&files=' . $files;
     // Determine the right URL, based on the frontend or backend
     if (JFactory::getApplication()->isSite() == true) {
         $url = JRoute::_($url);
     } else {
         $url = JURI::root() . $url;
     }
     // Domainname sharding
     $domain = $type == 'js' ? $this->params->get('js_domain') : $this->params->get('css_domain');
     $url = $this->replaceUrlDomain($url, $domain);
     // Protocol change
     if (JURI::getInstance()->isSSL()) {
         $url = str_replace('http://', 'https://', $url);
     } else {
         $url = str_replace('https://', 'http://', $url);
     }
     return $url;
 }