Skip to content
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
2 changes: 1 addition & 1 deletion ui/src/layout/layout-header/avatar/APIKeyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const props = defineProps({
})
const emit = defineEmits(['addData'])

const apiUrl = window.location.origin + +`${window.MaxKB.prefix}/api-doc/`
const apiUrl = window.location.origin + `${window.MaxKB.prefix}/api-doc/`
const SettingAPIKeyDialogRef = ref()
const dialogVisible = ref<boolean>(false)
const loading = ref(false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code appears to have a minor error: It's using + to concatenate a boolean value (window.maxKB.prefix === true) with a string, which can lead to unexpected results. Here is the corrected version:

if (window.MaxKB.prefix) {
  apiUrl = window.location.origin + `${window.MaxKB.prefix}/api-doc/`;
}

Optimization Suggestions:

  1. Inline Check: The condition inside the function call can be moved up into an inline if statement for better readability and performance.

This will ensure that the apiUrl variable is only set if window.MaxKB.prefix exists and is truthy. This avoids unnecessary computations and improves efficiency.

Expand Down
Loading