isDataURI method added

This commit is contained in:
Vladimir Enchev
2015-05-20 16:12:19 +03:00
parent 693b7d50f0
commit 191b91839e
2 changed files with 16 additions and 0 deletions

View File

@ -63,3 +63,13 @@ export function isFileOrResourcePath(path: string): boolean {
path.indexOf("/") === 0 || // absolute path
path.indexOf(RESOURCE_PREFIX) === 0; // resource
}
export function isDataURI(uri: string): boolean {
if (!types.isString(uri)) {
return false;
}
var firstSegment = uri.trim().split(',')[0];
return firstSegment && firstSegment.indexOf("data:") === 0 && firstSegment.indexOf('base64') >= 0;
}

6
utils/utils.d.ts vendored
View File

@ -140,4 +140,10 @@
* @param path The path.
*/
export function isFileOrResourcePath(path: string): boolean
/**
* Returns true if the specified URI is data URI (http://en.wikipedia.org/wiki/Data_URI_scheme).
* @param uri The URI.
*/
export function isDataURI(uri: string): boolean
}