Skip to content

Commit

Permalink
Merge pull request #7 from sailshq/feat/ignore-url-or-redirect
Browse files Browse the repository at this point in the history
feat(language-server): ignore url or redirect
  • Loading branch information
DominusKelvin authored Sep 11, 2024
2 parents 5ba87d2 + 289f294 commit 700dde8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/language-server/validators/validate-action-exist.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = function validateActionExist(document) {
const actions = extractActionInfo(document) // Get all actions

for (const { action, range } of actions) {
if (isUrlOrRedirect(action)) {
continue
}

const fullActionPath = resolveActionPath(projectRoot, action)
if (!fs.existsSync(url.fileURLToPath(fullActionPath))) {
const diagnostic = {
Expand Down Expand Up @@ -63,3 +67,15 @@ function extractActionInfo(document) {
function resolveActionPath(projectRoot, actionPath) {
return path.join(projectRoot, 'api', 'controllers', `${actionPath}.js`)
}

function isUrlOrRedirect(action) {
if (action.startsWith('http://') || action.startsWith('https://')) {
return true
}

if (action.startsWith('/')) {
return true
}

return false
}

0 comments on commit 700dde8

Please sign in to comment.