From 4c556a39a12881448246d263b639d4db6b84d0cf Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Mon, 22 Jun 2015 22:05:03 -0400 Subject: [PATCH] Tweaking buggy hash detection This should more appropriately detect the presence of the URL constructor, and will silently ignore any exceptions (and assume the hash isn't buggy) --- src/js/regexper.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/js/regexper.js b/src/js/regexper.js index 3057d81..fea7c4b 100644 --- a/src/js/regexper.js +++ b/src/js/regexper.js @@ -87,9 +87,14 @@ export default class Regexper { detectBuggyHash() { var url; - if (typeof window.URL !== 'undefined') { - url = new URL('http://regexper.com/#%25'); - this.buggyHash = (url.hash === '#%'); + if (typeof window.URL === 'function') { + try { + url = new URL('http://regexper.com/#%25'); + this.buggyHash = (url.hash === '#%'); + } + catch(e) { + this.buggyHash = false; + } } }