To allow only data URI as iOS does not support async image loading

This commit is contained in:
Minsuk Kang
2017-01-06 13:31:40 -08:00
parent cf974b64f8
commit 57c1fe5a96
+9 -5
View File
@@ -18,11 +18,15 @@ class Image extends Shape {
height: numberProp.isRequired,
href: PropTypes.oneOfType([
PropTypes.number,
PropTypes.shape({
uri: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired
})
function(props, propName, componentName) {
if (Object.keys(props[propName]).length != 1 ||
!/^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i.test(props[propName].uri)) {
return new Error(
'Invalid prop `' + propName + '` supplied to' +
' `' + componentName + '`. Validation failed.'
);
}
}
]).isRequired,
preserveAspectRatio: PropTypes.string
};