Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
baoduy committed Aug 23, 2018
1 parent cdb5148 commit 1a95fb0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/commons/commonFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ export function GetBaseUrl() {
export function newGuid() {
return uuidv4();
}

/**
*getImgSrc for both normal hosting and Reverse proxy
*
* @export
* @param {string} url the relative image url
* @returns real url
*/
export function getImgSrc(url) {
if (typeof url !== 'string') return url;
const base = GetBaseUrl();

if (!base || base === '/') return url;

if (url.indexOf(base) >= 0) return url;

return `${base}/${url}`;
return !base || base === '/' || url.indexOf(base) >= 0
? url
: `${base}/${url}`;
}

/**
*Merge second array to first array if existed then update.
*
Expand Down

0 comments on commit 1a95fb0

Please sign in to comment.