Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: more strict regex/host name checks
Browse files Browse the repository at this point in the history
kopernic-pl committed Jan 16, 2025
1 parent 74f9de1 commit a497b31
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
@@ -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 = {

0 comments on commit a497b31

Please sign in to comment.