2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2020-01-15 12:07:09 +00:00
|
|
|
* @copyright 2020 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-02-08 17:00:14 +00:00
|
|
|
/**
|
|
|
|
* Given a File and a baseURL value this returns the URL the File will use to download from.
|
|
|
|
*
|
|
|
|
* @function Phaser.Loader.GetURL
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Loader.File} file - The File object.
|
|
|
|
* @param {string} baseURL - A default base URL.
|
|
|
|
*
|
|
|
|
* @return {string} The URL the File will use.
|
|
|
|
*/
|
2016-12-01 12:50:58 +00:00
|
|
|
var GetURL = function (file, baseURL)
|
|
|
|
{
|
|
|
|
if (!file.url)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-02 11:30:33 +00:00
|
|
|
if (file.url.match(/^(?:blob:|data:|capacitor:\/\/|http:\/\/|https:\/\/|\/\/)/))
|
2016-12-01 12:50:58 +00:00
|
|
|
{
|
|
|
|
return file.url;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-08 16:21:16 +00:00
|
|
|
return baseURL + file.url;
|
2016-12-01 12:50:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetURL;
|