JS - 判断 url 是否为绝对路径 雾徊 2023-08-23 345 阅读1分钟 const isAbsolutePath = str => /^[a-z][a-z0-9+.-]*:/.test(str); isAbsolutePath('/user'); // false isAbsolutePath('http://'); // true isAbsolutePath('https://'); // true isAbsolutePath('ftp://'); // true isAbsolutePath('https://google.com'); // true