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

commaListsAnd returns undefined values when using function format #217

Open
pdehaan opened this issue Mar 30, 2022 · 0 comments
Open

commaListsAnd returns undefined values when using function format #217

pdehaan opened this issue Mar 30, 2022 · 0 comments

Comments

@pdehaan
Copy link

pdehaan commented Mar 30, 2022

Not sure if I'm using this correctly, but commaListsAnd returns undefined values when using function format.

const tags = require("common-tags");

const bar = ["one", "two", "three"];
console.log("1.", tags.commaListsAnd`${bar}`); // 1. one, two and three
console.log("2.", tags.commaListsAnd(bar)); // 2. oneundefinedtwoundefinedthree

I saw https://github.com/zspecza/common-tags#using-tags-on-regular-string-literals and wasn't sure if that worked w/ all tags, or just certain ones. I also tried w/ safeHtml() and got unexpected results, so I'm sure this might just be user error:

const someUnsafeString = `
<a href="script:alert('ok, computer')">
  Some link
    </a>
`;

console.log("3.", tags.safeHtml`${someUnsafeString}`);
console.log("4.", tags.safeHtml(someUnsafeString));

OUTPUT

3. &lt;a href=&quot;script:alert(&#x27;ok, computer&#x27;)&quot;&gt;   Some link     &lt;/a&gt;
4. <a href="script:alert('ok, computer')">
  Some link
    </a>
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

1 participant