Skip to content

Commit

Permalink
fix(curriculum): head content test (freeCodeCamp#56257)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasjorg authored Sep 30, 2024
1 parent 03fa03c commit 0f5cb9d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ const target = meta?.find(m => m?.getAttribute('name')?.toLowerCase()?.replace(/
assert.exists(target);
```
Your new `meta` element should be inside the `head` element.
Your two `meta` elements should be inside the `head` element.
```js
const metaElementRegex = /<head\s*>(?:.|\r|\n)*?<meta\s+name\s*=\s*('|"|`)\s*viewport\s*\1\s+content\s*=\s*\1\s*width\s*=\s*device-width\s*,\s*initial-scale\s*=\s*1(?:\.0)?\s*\1(?:.|\r|\n)*?<\/head\s*>/i;
assert.match(code, metaElementRegex);
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
const headElementContent = code.match(headContentRegex);

const headElement = document.createElement("head");
headElement.innerHTML = headElementContent;
assert.strictEqual(headElement.querySelectorAll('meta').length, 2);
```
# --seed--
Expand Down

0 comments on commit 0f5cb9d

Please sign in to comment.