original_string: protected function js_fix_url($url) {
          global $CFG;
  
          if ($url instanceof moodle_url) {
              return $url;
          } else if (strpos($url, '/') === 0) {
              // Fix the admin links if needed.
              if ($CFG->admin !== 'admin') {
                  if (strpos($url, "/admin/") === 0) {
                      $url = preg_replace("|^/admin/|", "/$CFG->admin/", $url);
                  }
              }
              if (debugging()) {
                  // Check file existence only when in debug mode.
                  if (!file_exists($CFG->dirroot . strtok($url, '?'))) {
                      throw new coding_exception('Attempt to require a JavaScript file that does not exist.', $url);
                  }
              }
              if (substr($url, -3) === '.js') {
                  $jsrev = $this->get_jsrev();
                  if (empty($CFG->slasharguments)) {
                      return new moodle_url('/lib/javascript.php', array('rev'=>$jsrev, 'jsfile'=>$url));
                  } else {
                      $returnurl = new moodle_url('/lib/javascript.php');
                      $returnurl->set_slashargument('/'.$jsrev.$url);
                      return $returnurl;
                  }
              } else {
                  return new moodle_url($url);
              }
          } else {
              throw new coding_exception('Invalid JS url, it has to be shortened url starting with / or moodle_url instance.', $url);
          }
      }
code: protected function js_fix_url($url) {
          global $CFG;
  
          if ($url instanceof moodle_url) {
              return $url;
          } else if (strpos($url, '/') === 0) {
              // Fix the admin links if needed.
              if ($CFG->admin !== 'admin') {
                  if (strpos($url, "/admin/") === 0) {
                      $url = preg_replace("|^/admin/|", "/$CFG->admin/", $url);
                  }
              }
              if (debugging()) {
                  // Check file existence only when in debug mode.
                  if (!file_exists($CFG->dirroot . strtok($url, '?'))) {
                      throw new coding_exception('Attempt to require a JavaScript file that does not exist.', $url);
                  }
              }
              if (substr($url, -3) === '.js') {
                  $jsrev = $this->get_jsrev();
                  if (empty($CFG->slasharguments)) {
                      return new moodle_url('/lib/javascript.php', array('rev'=>$jsrev, 'jsfile'=>$url));
                  } else {
                      $returnurl = new moodle_url('/lib/javascript.php');
                      $returnurl->set_slashargument('/'.$jsrev.$url);
                      return $returnurl;
                  }
              } else {
                  return new moodle_url($url);
              }
          } else {
              throw new coding_exception('Invalid JS url, it has to be shortened url starting with / or moodle_url instance.', $url);
          }
      }
code_tokens: protected function js_fix_url ( $ url ) { global $ CFG ; if ( $ url instanceof moodle_url ) { return $ url ; } else if ( strpos ( $ url , '/' ) === 0 ) { // Fix the admin links if needed. if ( $ CFG -> admin !== 'admin' ) { if ( strpos ( $ url , "/admin/" ) === 0 ) { $ url = preg_replace ( "|^/admin/|" , "/$CFG->admin/" , $ url ) ; } } if ( debugging ( ) ) { // Check file existence only when in debug mode. if ( ! file_exists ( $ CFG -> dirroot . strtok ( $ url , '?' ) ) ) { throw new coding_exception ( 'Attempt to require a JavaScript file that does not exist.' , $ url ) ; } } if ( substr ( $ url , - 3 ) === '.js' ) { $ jsrev = $ this -> get_jsrev ( ) ; if ( empty ( $ CFG -> slasharguments ) ) { return new moodle_url ( '/lib/javascript.php' , array ( 'rev' => $ jsrev , 'jsfile' => $ url ) ) ; } else { $ returnurl = new moodle_url ( '/lib/javascript.php' ) ; $ returnurl -> set_slashargument ( '/' . $ jsrev . $ url ) ; return $ returnurl ; } } else { return new moodle_url ( $ url ) ; } } else { throw new coding_exception ( 'Invalid JS url, it has to be shortened url starting with / or moodle_url instance.' , $ url ) ; } }
docstring: Returns the actual url through which a script is served.
  
  @param moodle_url|string $url full moodle url, or shortened path to script
  @return moodle_url
docstring_tokens: Returns the actual url through which a script is served .