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

[parse] Trim input, fixes #196 #197

Merged
merged 4 commits into from
Jul 18, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ColorSpace from "./space.js";

// CSS color to Color object
export default function parse (str) {
let env = {str};
let env = {"str": str?.trim()};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we may want to coerce to a string here as well (str + "") before trimming.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

-let env = {"str": str?.trim()};
+let env = {"str": (str+"")?.trim()};

The parentheses could also be removed (just preference).

hooks.run("parse-start", env);

if (env.color) {
Expand Down