mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
isDataURI method added
This commit is contained in:
@ -62,4 +62,14 @@ export function isFileOrResourcePath(path: string): boolean {
|
||||
return path.indexOf("~/") === 0 || // relative to AppRoot
|
||||
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
6
utils/utils.d.ts
vendored
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user