视频链接地址

验证视频链接地址,视频格式 可按需增删,必须包含 http/https

语法

  1. import { videoUrlReg } from 'warbler-js';
  2. const result = videoUrlReg(value);

参数

  • value (String) : 待验证字符串。

返回值

Boolean : 是否通过验证,true 通过验证, false 没有通过验证。

源码

  1. const videoUrlReg = (value) => {
  2. const reg = /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i;
  3. return reg.test(value);
  4. };

例子

  1. import { videoUrlReg } from 'warbler-js';
  2. const result1 = videoUrlReg('http://warbler.duwanyu.com/wc.mp4')
  3. const result2 = videoUrlReg('https://warbler.duwanyu.com/wc.mp4')
  4. const result3 = videoUrlReg('warbler.duwanyu.com/wc.mp4')
  5. console.log(result1) // true
  6. console.log(result2) // true
  7. console.log(result3) // false