Repository: TheOdinProject/odin-bot-v2
Pull request #517 (2024-03-18 07:57:22)

Bump axios from 1.6.7 to 1.6.8
Bumps [axios](https://github.com/axios/axios) from 1.6.7 to 1.6.8.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/axios/axios/releases">axios's releases</a>.</em></p>
<blockquote>
<h2>Release v1.6.8</h2>
<h2>Release notes:</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>AxiosHeaders:</strong> fix AxiosHeaders conversion to an object during config merging (<a href="https://redirect.github.com/axios/axios/issues/6243">#6243</a>) (<a href="https://github.com/axios/axios/commit/2656612bc10fe2757e9832b708ed773ab340b5cb">2656612</a>)</li>
<li><strong>import:</strong> use named export for EventEmitter; (<a href="https://github.com/axios/axios/commit/7320430aef2e1ba2b89488a0eaf42681165498b1">7320430</a>)</li>
<li><strong>vulnerability:</strong> update follow-redirects to 1.15.6 (<a href="https://redirect.github.com/axios/axios/issues/6300">#6300</a>) (<a href="https://github.com/axios/axios/commit/8786e0ff55a8c68d4ca989801ad26df924042e27">8786e0f</a>)</li>
</ul>
<h3>Contributors to this release</h3>
<ul>
<li><!-- raw HTML omitted --> <a href="https://github.com/jasonsaayman" title="+4572/-3446 ([#6238](https://github.com/axios/axios/issues/6238) )">Jay</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/DigitalBrainJS" title="+30/-0 ([#6231](https://github.com/axios/axios/issues/6231) )">Dmitriy Mozgovoy</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/Creaous" title="+9/-9 ([#6300](https://github.com/axios/axios/issues/6300) )">Mitchell</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/mannoeu" title="+2/-2 ([#6196](https://github.com/axios/axios/issues/6196) )">Emmanuel</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/ljkeller" title="+3/-0 ([#6194](https://github.com/axios/axios/issues/6194) )">Lucas Keller</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/ADITYA-176" title="+1/-1 ()">Aditya Mogili</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/petrovmiroslav" title="+1/-1 ([#6243](https://github.com/axios/axios/issues/6243) )">Miroslav Petrov</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/axios/axios/blob/v1.x/CHANGELOG.md">axios's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/axios/axios/compare/v1.6.7...v1.6.8">1.6.8</a> (2024-03-15)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>AxiosHeaders:</strong> fix AxiosHeaders conversion to an object during config merging (<a href="https://redirect.github.com/axios/axios/issues/6243">#6243</a>) (<a href="https://github.com/axios/axios/commit/2656612bc10fe2757e9832b708ed773ab340b5cb">2656612</a>)</li>
<li><strong>import:</strong> use named export for EventEmitter; (<a href="https://github.com/axios/axios/commit/7320430aef2e1ba2b89488a0eaf42681165498b1">7320430</a>)</li>
<li><strong>vulnerability:</strong> update follow-redirects to 1.15.6 (<a href="https://redirect.github.com/axios/axios/issues/6300">#6300</a>) (<a href="https://github.com/axios/axios/commit/8786e0ff55a8c68d4ca989801ad26df924042e27">8786e0f</a>)</li>
</ul>
<h3>Contributors to this release</h3>
<ul>
<li><!-- raw HTML omitted --> <a href="https://github.com/jasonsaayman" title="+4572/-3446 ([#6238](https://github.com/axios/axios/issues/6238) )">Jay</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/DigitalBrainJS" title="+30/-0 ([#6231](https://github.com/axios/axios/issues/6231) )">Dmitriy Mozgovoy</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/Creaous" title="+9/-9 ([#6300](https://github.com/axios/axios/issues/6300) )">Mitchell</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/mannoeu" title="+2/-2 ([#6196](https://github.com/axios/axios/issues/6196) )">Emmanuel</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/ljkeller" title="+3/-0 ([#6194](https://github.com/axios/axios/issues/6194) )">Lucas Keller</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/ADITYA-176" title="+1/-1 ()">Aditya Mogili</a></li>
<li><!-- raw HTML omitted --> <a href="https://github.com/petrovmiroslav" title="+1/-1 ([#6243](https://github.com/axios/axios/issues/6243) )">Miroslav Petrov</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/axios/axios/commit/ab3f0f9a94853c821cb00f1112788ecdd3ae7ed1"><code>ab3f0f9</code></a> chore(release): v1.6.8 (<a href="https://redirect.github.com/axios/axios/issues/6303">#6303</a>)</li>
<li><a href="https://github.com/axios/axios/commit/2656612bc10fe2757e9832b708ed773ab340b5cb"><code>2656612</code></a> fix(AxiosHeaders): fix AxiosHeaders conversion to an object during config mer...</li>
<li><a href="https://github.com/axios/axios/commit/7320430aef2e1ba2b89488a0eaf42681165498b1"><code>7320430</code></a> fix(import): use named export for EventEmitter;</li>
<li><a href="https://github.com/axios/axios/commit/8786e0ff55a8c68d4ca989801ad26df924042e27"><code>8786e0f</code></a> fix(vulnerability): update follow-redirects to 1.15.6 (<a href="https://redirect.github.com/axios/axios/issues/6300">#6300</a>)</li>
<li><a href="https://github.com/axios/axios/commit/d844227411263fab39d447442879112f8b0c8de5"><code>d844227</code></a> chore: update and bump deps (<a href="https://redirect.github.com/axios/axios/issues/6238">#6238</a>)</li>
<li><a href="https://github.com/axios/axios/commit/caa06252015003990958d7db96f63aa646bc58e8"><code>caa0625</code></a> docs: update README responseEncoding types (<a href="https://redirect.github.com/axios/axios/issues/6194">#6194</a>)</li>
<li><a href="https://github.com/axios/axios/commit/41c4584a41fad1d94cf86331667deff5a0b75044"><code>41c4584</code></a> docs: Update README.md to point to current axios version in CDN links (<a href="https://redirect.github.com/axios/axios/issues/6196">#6196</a>)</li>
<li><a href="https://github.com/axios/axios/commit/bf6974f16af6c72985f094a98d874c5a6adcdc83"><code>bf6974f</code></a> chore(ci): add npm tag action; (<a href="https://redirect.github.com/axios/axios/issues/6231">#6231</a>)</li>
<li>See full diff in <a href="https://github.com/axios/axios/compare/v1.6.7...v1.6.8">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=axios&package-manager=npm_and_yarn&previous-version=1.6.7&new-version=1.6.8)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/package-lock.json b/package-lock.json
index 8d7125a..755c76a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,7 @@
       "license": "ISC",
       "dependencies": {
         "@discordjs/rest": "^2.2.0",
-        "axios": "^1.6.7",
+        "axios": "^1.6.8",
         "discord-api-types": "^0.37.73",
         "discord.js": "^14.14.1",
         "dotenv": "^16.4.5",
@@ -3191,11 +3191,11 @@
       }
     },
     "node_modules/axios": {
-      "version": "1.6.7",
-      "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
-      "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
+      "version": "1.6.8",
+      "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
+      "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
       "dependencies": {
-        "follow-redirects": "^1.15.4",
+        "follow-redirects": "^1.15.6",
         "form-data": "^4.0.0",
         "proxy-from-env": "^1.1.0"
       }
@@ -4767,9 +4767,9 @@
       "dev": true
     },
     "node_modules/follow-redirects": {
-      "version": "1.15.4",
-      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
-      "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
+      "version": "1.15.6",
+      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+      "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
       "funding": [
         {
           "type": "individual",
@@ -10949,11 +10949,11 @@
       "dev": true
     },
     "axios": {
-      "version": "1.6.7",
-      "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
-      "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
+      "version": "1.6.8",
+      "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
+      "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
       "requires": {
-        "follow-redirects": "^1.15.4",
+        "follow-redirects": "^1.15.6",
         "form-data": "^4.0.0",
         "proxy-from-env": "^1.1.0"
       },
@@ -12106,9 +12106,9 @@
       "dev": true
     },
     "follow-redirects": {
-      "version": "1.15.4",
-      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
-      "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw=="
+      "version": "1.15.6",
+      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+      "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA=="
     },
     "for-each": {
       "version": "0.3.3",
diff --git a/package.json b/package.json
index 0949593..6c88e84 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
   "license": "ISC",
   "dependencies": {
     "@discordjs/rest": "^2.2.0",
-    "axios": "^1.6.7",
+    "axios": "^1.6.8",
     "discord-api-types": "^0.37.73",
     "discord.js": "^14.14.1",
     "dotenv": "^16.4.5",
diff --git a/services/update-faq/update-faq.service.js b/services/update-faq/update-faq.service.js
index 7efe461..7dcca51 100644
--- a/services/update-faq/update-faq.service.js
+++ b/services/update-faq/update-faq.service.js
@@ -46,29 +46,28 @@ class UpdateFAQsService {
     prev.forEach((message) => message.delete());
   }
 
-  static segments(string, length, delimiter, doNotPrependDelimiter) {
+  static segments(string, length, delimiter, prependDelimiter = true) {
     const segmentedString = string.split(delimiter)
     const segments = []
     let currentSection = ""
 
     for (let i = 0; i < segmentedString.length; i += 1) {
-      let segment = segmentedString[i]
+      const segment = prependDelimiter ? delimiter + segmentedString[i] : segmentedString[i];
 
-      if (!doNotPrependDelimiter) {
-        segment = delimiter + segmentedString[i]
-      }
       if (segmentedString[i] === '') {
         // eslint-disable-next-line no-continue
-        continue
+        continue;
       }
+
       if ((currentSection.length + segment.length) >= length) {
-          segments.push(currentSection)
-          currentSection = segment
+        segments.push(currentSection);
+        currentSection = segment;
       } else {
-        currentSection += segment
+        currentSection += segment;
       }
     }
-    segments.push(currentSection)
+
+    segments.push(currentSection);
     return segments;
   }
 }


Test patch:
diff --git a/services/update-faq/update-faq.service.test.js b/services/update-faq/update-faq.service.test.js
index 0494750..9a9429b 100644
--- a/services/update-faq/update-faq.service.test.js
+++ b/services/update-faq/update-faq.service.test.js
@@ -49,7 +49,7 @@ describe('UpdateFAQsService', () => {
         const string = '### The Odin Project.### Your Career in Web Development starts here';
         const delimiter = '###'
         const length = 25;
-        const result = UpdateFAQsService.segments(string, length, delimiter, true);
+        const result = UpdateFAQsService.segments(string, length, delimiter, false);
         expect(result).toEqual([' The Odin Project.', ' Your Career in Web Development starts here']);
       })
     })
@@ -69,7 +69,7 @@ describe('UpdateFAQsService', () => {
         const string = 'The Odin Project. Your Career in Web Development starts here';
         const delimiter = '###'
         const length = 75;
-        const result = UpdateFAQsService.segments(string, length, delimiter, true);
+        const result = UpdateFAQsService.segments(string, length, delimiter, false);
         expect(result).toEqual(['The Odin Project. Your Career in Web Development starts here']);
       })
     })