Skip to content

Commit

Permalink
another attempt to fix ayastreb#23
Browse files Browse the repository at this point in the history
  • Loading branch information
changhaitravis committed Jun 14, 2019
1 parent f890973 commit 0e1f82c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/background/shouldCompress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@ import { Netmask } from 'netmask'

export default ({ imageUrl, pageUrl, compressed, proxyUrl, disabledHosts, enabled }) => {
imageUrl = imageUrl.replace('#bh-no-compress=1', '')
const skip = [proxyUrl, 'favicon', '.*\\.ico', '.*\\.svg'].concat(disabledHosts)
const skip = [proxyUrl, 'favicon', '.*\\.ico', '.*\\.svg'].concat(
disabledHosts
.filter(
(disabledHost) => {
return disabledHost && disabledHost.length > 3 && disabledHost.includes('.')
}
)
.map( //sanitize for regExp
(disabledHost) => {
return disabledHost
.replace('.', '\\.')
.replace('?', '\\?')
.replace('+', '\\+')
.replace('*', '\\*');
}
)
)
const skipRegExp = new RegExp(`(${skip.join('|')})`, 'i')

console.log(pageUrl, disabledHosts);

return (
enabled &&
Expand Down

0 comments on commit 0e1f82c

Please sign in to comment.