text: 'use strict';
  
  var _Link = require('../Link');
  
  var _Link2 = _interopRequireDefault(_Link);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  module.exports = function (pathname) {
      var _this = this;
  
      var link = new _Link2.default();
      link.setPath(pathname);
      return new Promise(function (resolve, reject) {
          if (link.getAddress() != _this.currentUrl && !_this.cache.exists(link.getAddress())) {
              _this.getPage({ url: link.getAddress() }, function (response, request) {
                  if (request.status === 500) {
                      _this.triggerEvent('serverError');
                      reject();
                  } else {
                      // get json data
                      var page = _this.getDataFromHtml(response, request);
                      if (page != null) {
                          page.url = link.getAddress();
                          _this.cache.cacheUrl(page, _this.options.debugMode);
                          _this.triggerEvent('pagePreloaded');
                      }
                      resolve(_this.cache.getPage(link.getAddress()));
                  }
              });
          } else {
              resolve(_this.cache.getPage(link.getAddress()));
          }
      });
  };