fix(curriculum): slice range (#52712)

This commit is contained in:
Krzysztof G
2023-12-22 15:15:38 +01:00
committed by GitHub
parent 33933a2369
commit c2ad6396d6
3 changed files with 5 additions and 5 deletions
@@ -34,13 +34,13 @@ assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50/)
If the `bio` text is greater than `50` characters, you should extract the first 50 characters with `slice()` and replace the rest with `...`. Don't forget that indexes are zero-based.
```js
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*49\s*\)\s*\+\s*("|')\.\.\.\2\s*\:/)
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*50\s*\)\s*\+\s*("|')\.\.\.\2\s*\:/)
```
If the `bio` text is less than 50 characters, use the `bio` text directly.
```js
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*49\s*\)\s*\+\s*("|')\.\.\.\2\s*\:\s*bio\s*\}<\/p>/)
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*50\s*\)\s*\+\s*("|')\.\.\.\2\s*\:\s*bio\s*\}<\/p>/)
```
@@ -180,7 +180,7 @@ const displayAuthors = (authors) => {
<h2 class="author-name">${author}</h2>
<img class="user-img" src="${image}" alt="${author} avatar" />
<div class="purple-divider"></div>
<p class="bio">${bio.length > 50 ? bio.slice(0, 49) + '...' : bio}</p>
<p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
<a class="author-link" href="${url}" target="_blank">${author} author page</a>
</div>
`;
@@ -174,7 +174,7 @@ const displayAuthors = (authors) => {
<h2 class="author-name">${author}</h2>
<img class="user-img" src="${image}" alt="${author} avatar">
<div class="purple-divider"></div>
<p class="bio">${bio.length > 50 ? bio.slice(0, 49) + '...' : bio}</p>
<p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
<a class="author-link" href="${url}" target="_blank">${author} author page</a>
</div>
`;
@@ -321,7 +321,7 @@ const displayAuthors = (authors) => {
<h2 class="author-name">${author}</h2>
<img class="user-img" src="${image}" alt="${author} avatar" />
<div class="purple-divider"></div>
<p class="bio">${bio.length > 50 ? bio.slice(0, 49) + '...' : bio}</p>
<p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
<a class="author-link" href="${url}" target="_blank">${author} author page</a>
</div>
`;