UNPKG

javascriptx

Version:

javascript 基础库扩展

35 lines (31 loc) 1.11 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; // Image var url = function url(_url, hasBaseUrl) { if (!_url) { return _url; } if ((typeof _url === 'undefined' ? 'undefined' : _typeof(_url)) === 'object' && _url._url) { return window._baseURL + '/' + _url._url; } if (_url.indexOf(window._baseURL) === 0) { return _url; } if (_url.indexOf('@/') === 0) { return _url.replace('@', window._pageURL); } if (!hasBaseUrl && _url.indexOf('/') === 0) { return window._baseURL + _url; } if (_url.indexOf('~/') === 0) { return _url.replace('~/', window._baseURL); } if (!hasBaseUrl && _url.indexOf('../') === 0) { return _url.replace('../', window._baseURL); } return _url; }; exports.default = url;