mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): head content test (#56257)
This commit is contained in:
+7
-3
@@ -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--
|
||||
|
||||
Reference in New Issue
Block a user