Skip to content

Commit

Permalink
Added Base64 and blob check in Asset#getAbsoluteUrl (#3159)
Browse files Browse the repository at this point in the history
* Added Base64 and blob check in Asset#getAbsoluteUrl

* Update src/asset/asset.js

Co-authored-by: Steven Yau <syau@snapchat.com>
  • Loading branch information
yaustar and steveny-sc committed May 12, 2021
1 parent 5cd4bf6 commit bbfdf57
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/asset/asset.js
Expand Up @@ -230,11 +230,16 @@ class Asset extends EventHandler {
* @private
* @function
* @name Asset#getAbsoluteUrl
* @description Construct an asset URL from this asset's location and a relative path.
* @description Construct an asset URL from this asset's location and a relative path. If the relativePath is a
* blob or Base64 URI, then return that instead.
* @param {string} relativePath - The relative path to be concatenated to this asset's base url.
* @returns {string} Resulting URL of the asset.
*/
getAbsoluteUrl(relativePath) {
if (relativePath.startsWith('blob:') || relativePath.startsWith('data:')) {
return relativePath;
}

var base = path.getDirectory(this.file.url);
return path.join(base, relativePath);
}
Expand Down

0 comments on commit bbfdf57

Please sign in to comment.