Skip to content

Commit

Permalink
fix: more strict regex/host name checks (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
kopernic-pl authored Jan 17, 2025
1 parent 90d6a8c commit c1c1bea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const setConfig = update => {

const isURLValid = () => {
const { SWAGGERHUB_URL } = getConfig()
const url = new URL(SWAGGERHUB_URL)
return swaggerhubUrlRegex.test(SWAGGERHUB_URL) ||
(!SWAGGERHUB_URL.includes('api.swaggerhub.com') && SWAGGERHUB_URL.endsWith('/v1')) ||
SWAGGERHUB_URL.includes('localhost')
(!url.hostname.endsWith('api.swaggerhub.com') && url.pathname.endsWith('/v1')) ||
url.hostname === 'localhost'
}

module.exports = {
Expand Down

0 comments on commit c1c1bea

Please sign in to comment.