Skip to content
Permalink
Browse files

chore: fixup helper

  • Loading branch information...
MarshallOfSound committed Mar 28, 2019
1 parent 6bc9ebb commit 7f617743ceab3a3b405b224c7a44dff1b987c2c5
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/renderer/content-scripts-injector.js
@@ -4,14 +4,14 @@ const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
const { runInThisContext } = require('vm')

const escapePattern = function (pattern) {
return pattern.split('*').map(x => x.replace(/[\\^$+?.()|[\]{}]/g, '\\$&'))).join('.*')
return pattern.replace(/[\\^$+?.()|[\]{}]/g, '\\$&')
}

// Check whether pattern matches.
// https://developer.chrome.com/extensions/match_patterns
const matchesPattern = function (pattern) {
if (pattern === '<all_urls>') return true
const regexp = new RegExp(`^${escapePattern(pattern)}$`)
const regexp = new RegExp(`^${pattern.split('*').map(escapePattern).join('.*')}$`)
const url = `${location.protocol}//${location.host}${location.pathname}`
return url.match(regexp)
}

0 comments on commit 7f61774

Please sign in to comment.
You can’t perform that action at this time.