validUrl.js 266B

12345678910111213
  1. import invariant from 'invariant'
  2. export default arg => {
  3. invariant(
  4. typeof arg === 'string',
  5. 'expect url is string type, but get %s', typeof arg
  6. )
  7. invariant(
  8. /^https?:\/\//.test(arg),
  9. 'expect url is valid http address, but get %s', arg
  10. )
  11. }