From ac0588093499d9a32ad7c5194223cee8dbf48a03 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Fri, 21 Dec 2018 16:51:20 +0300 Subject: [PATCH] fix(isUrlRequest): ignore `about:blank` --- lib/isUrlRequest.js | 2 +- test/isUrlRequest.test.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/isUrlRequest.js b/lib/isUrlRequest.js index ed5789b..8e7831d 100644 --- a/lib/isUrlRequest.js +++ b/lib/isUrlRequest.js @@ -5,7 +5,7 @@ function isUrlRequest(url, root) { // 1. it's a Data Url // 2. it's an absolute url or and protocol-relative // 3. it's some kind of url for a template - if(/^data:|^.+-extension:\/|^(https?:)?\/\/|^[\{\}\[\]#*;,'§\$%&\(=?`´\^°<>]/.test(url)) { + if(/^data:|^.+-extension:\/|^about:blank$|^(https?:)?\/\/|^[\{\}\[\]#*;,'§\$%&\(=?`´\^°<>]/.test(url)) { return false; } diff --git a/test/isUrlRequest.test.js b/test/isUrlRequest.test.js index bab4e0e..80c4da4 100644 --- a/test/isUrlRequest.test.js +++ b/test/isUrlRequest.test.js @@ -51,7 +51,10 @@ describe("isUrlRequest()", () => { [["/path/to/thing", 1], new ExpectedError(/unexpected parameters/i), "should throw an error on invalid root"], // empty url - [[""], true, "should be positive if url is empty"] + [[""], true, "should be positive if url is empty"], + + // about url + [["about:blank"], false, "should be negative for about:blank"] ].forEach((test) => { it(test[2], () => { const expected = test[1];