Skip to content

Commit

Permalink
Simplify string comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
proginosko committed Dec 18, 2017
1 parent d8d1065 commit d11fd46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function getParsedURL(url) {
// Create regular expressions for matching sites to block/allow
//
function getRegExpSites(sites) {
if (sites == "") {
if (!sites) {
return {
block: "",
allow: "",
Expand Down Expand Up @@ -257,8 +257,8 @@ function keywordToRegExp(keyword) {
// Test URL against block/allow regular expressions
//
function testURL(pageURL, blockRE, allowRE) {
return (blockRE != "" && (new RegExp(blockRE, "i")).test(pageURL)
&& !(allowRE != "" && (new RegExp(allowRE, "i")).test(pageURL)));
return (blockRE && (new RegExp(blockRE, "i")).test(pageURL)
&& !(allowRE && (new RegExp(allowRE, "i")).test(pageURL)));
}

// Check time periods format
Expand All @@ -277,7 +277,7 @@ function checkPosIntFormat(value) {
//
function getMinPeriods(times) {
let minPeriods = [];
if (times != "") {
if (times) {
let regexp = /^(\d\d)(\d\d)-(\d\d)(\d\d)$/;
let periods = times.split(/[, ]+/);
for (let period of periods) {
Expand Down
4 changes: 2 additions & 2 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function retrieveOptions() {

// Check time periods
let withinTimePeriods = false;
if (onSelectedDay && times != "") {
if (onSelectedDay && times) {
// Get number of minutes elapsed since midnight
let mins = timedate.getHours() * 60 + timedate.getMinutes();

Expand All @@ -212,7 +212,7 @@ function retrieveOptions() {

// Check time limit
let afterTimeLimit = false;
if (onSelectedDay && limitMins != "" && limitPeriod != "") {
if (onSelectedDay && limitMins && limitPeriod) {
// Check time period and time limit
if (timedata[2] == periodStart && timedata[3] >= (limitMins * 60)) {
afterTimeLimit = true;
Expand Down

0 comments on commit d11fd46

Please sign in to comment.