Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle lookup errors in resolveDjangoUrl #3204

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions vue/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,22 @@ export const ResolveUrlMixin = {
}

export function resolveDjangoUrl(url, params = null) {
let fun = window.Urls[url];
if (typeof fun !== 'function') {
console.error(`window.Urls[${url}] is not a function: ${fun}`);
return
}
if (params == null) {
return window.Urls[url]()
return fun()
} else if (typeof params != "object") {
return window.Urls[url](params)
return fun(params)
} else if (typeof params == "object") {
if (params.length === 1) {
return window.Urls[url](params)
return fun(params)
} else if (params.length === 2) {
return window.Urls[url](params[0], params[1])
return fun(params[0], params[1])
} else if (params.length === 3) {
return window.Urls[url](params[0], params[1], params[2])
return fun(params[0], params[1], params[2])
}
}
}
Expand Down Expand Up @@ -774,4 +779,4 @@ export const formFunctions = {
}
return form
},
}
}