Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkFalsePositiveDate(dateString = '') breaks IE #404

Closed
domehead100 opened this issue Jan 12, 2021 · 4 comments
Closed

checkFalsePositiveDate(dateString = '') breaks IE #404

domehead100 opened this issue Jan 12, 2021 · 4 comments

Comments

@domehead100
Copy link

IE breaks on default parameters for functions. Better to null check inside the body. Also default params only replace the missing param if it is undefined, whereas null would not get replaced, causing the code to blow up inside the function body.

@mikeerickson
Copy link
Owner

@domehead100 can you please supply example code, I am not sure what you are stating here is the issue

@domehead100
Copy link
Author

Sorry, in a hurry. In rules.js:

// --> default paramater in the line below breaks IE
function checkFalsePositiveDates(dateString = '') {

  // --> if null is passed in, it will not get replaced with empty string, and the line below will error
  if (dateString.length === 10) {

    // massage input to use yyyy-mm-dd format
    // we support yyyy/mm/dd or yyyy.mm.dd
    let normalizedDate = dateString.replace('.', '-').replace('/', '-');
    let parts = normalizedDate.split('-');
    if (parts.length === 3) {
      if (parts[0].length === 4) {
        // yyyy-mm-dd format
        let y = parseInt(parts[0]);
        let m = parseInt(parts[1]);
        let d = parseInt(parts[2]);
        if (m === 2) {
          // return leapYear(y) ? d <= 29 : d <= 28;
          if (leapYear(y)) {
            if (d > 29) {
              return false;
            }
          } else {
            if (d > 28) {
              return false;
            }
          }
        }
        if (m === 4 || m === 6 || m === 9 || m === 11) {
          if (d > 30) {
            return false;
          }
        }
      }
    }
    return true; // we are not in feburary, proceed
  }
  return true; // we are not testing formatted date, proceed to rest of validation
}

@mikeerickson
Copy link
Owner

I understand the code referenced above, it has been in place for many years. Can you provide the validation code in question. I am keen to adjust, but need some more detail when it “blows up”

@mikeerickson
Copy link
Owner

Fixed in 3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants