Skip to content

Commit 191b918

Browse files
author
Vladimir Enchev
committed
isDataURI method added
1 parent 693b7d5 commit 191b918

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

utils/utils-common.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,14 @@ export function isFileOrResourcePath(path: string): boolean {
6262
return path.indexOf("~/") === 0 || // relative to AppRoot
6363
path.indexOf("/") === 0 || // absolute path
6464
path.indexOf(RESOURCE_PREFIX) === 0; // resource
65+
}
66+
67+
export function isDataURI(uri: string): boolean {
68+
if (!types.isString(uri)) {
69+
return false;
70+
}
71+
72+
var firstSegment = uri.trim().split(',')[0];
73+
74+
return firstSegment && firstSegment.indexOf("data:") === 0 && firstSegment.indexOf('base64') >= 0;
6575
}

utils/utils.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,10 @@
140140
* @param path The path.
141141
*/
142142
export function isFileOrResourcePath(path: string): boolean
143+
144+
/**
145+
* Returns true if the specified URI is data URI (http://en.wikipedia.org/wiki/Data_URI_scheme).
146+
* @param uri The URI.
147+
*/
148+
export function isDataURI(uri: string): boolean
143149
}

0 commit comments

Comments
 (0)