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

What's the purpose of the options.sameSite branch of ternary in serialize? #206

Open
jonchurch opened this issue Nov 15, 2024 · 1 comment · May be fixed by #207
Open

What's the purpose of the options.sameSite branch of ternary in serialize? #206

jonchurch opened this issue Nov 15, 2024 · 1 comment · May be fixed by #207

Comments

@jonchurch
Copy link
Member

jonchurch commented Nov 15, 2024

What's the purpose of the options.sameSite branch of ternary in serialize?

When options.priority is not a string, it will use options.sameSite. There's no overlap in the types between the two, so we'd hit the default and throw. Was there meant to be overlap or is this a typo?

: options.sameSite;

  if (options.priority) {
    const priority =
      typeof options.priority === "string"
        ? options.priority.toLowerCase()
        : options.sameSite; // typo?
    switch (priority) {
      case "low":
        str += "; Priority=Low";
        break;
      case "medium":
        str += "; Priority=Medium";
        break;
      case "high":
        str += "; Priority=High";
        break;
      default:
        throw new TypeError(`option priority is invalid: ${options.priority}`);
    }
  }
@jonchurch
Copy link
Member Author

It's functionally sound, non strings will throw with the correct error, except in the edgecase where someone did {priority: 1, sameSite: "low"}

That still throws, but only once we validate options.sameSite

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

Successfully merging a pull request may close this issue.

1 participant