isUrlRequest.js 515B

123456789101112131415
  1. "use strict";
  2. function isUrlRequest(url, root) {
  3. // An URL is not an request if
  4. // 1. it's a Data Url
  5. // 2. it's an absolute url or and protocol-relative
  6. // 3. it's some kind of url for a template
  7. if(/^data:|^chrome-extension:|^(https?:)?\/\/|^[\{\}\[\]#*;,'§\$%&\(=?`´\^°<>]/.test(url)) return false;
  8. // 4. It's also not an request if root isn't set and it's a root-relative url
  9. if((root === undefined || root === false) && /^\//.test(url)) return false;
  10. return true;
  11. }
  12. module.exports = isUrlRequest;