视频链接地址
验证视频链接地址,视频格式
可按需增删,必须包含 http/https
。
语法
import { videoUrlReg } from 'warbler-js';
const result = videoUrlReg(value);
参数
value
(String) : 待验证字符串。
返回值
Boolean : 是否通过验证,true
通过验证, false
没有通过验证。
源码
const videoUrlReg = (value) => {
const reg = /^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i;
return reg.test(value);
};
例子
import { videoUrlReg } from 'warbler-js';
const result1 = videoUrlReg('http://warbler.duwanyu.com/wc.mp4')
const result2 = videoUrlReg('https://warbler.duwanyu.com/wc.mp4')
const result3 = videoUrlReg('warbler.duwanyu.com/wc.mp4')
console.log(result1) // true
console.log(result2) // true
console.log(result3) // false