UNPKG

tongtong-utils

Version:

String类

28 lines (26 loc) 993 B
'use strict'; 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.url = function (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; };