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

fix companion implicitpath #4484

Merged
merged 3 commits into from
Jun 8, 2023
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
24 changes: 14 additions & 10 deletions packages/@uppy/companion/src/server/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,28 @@ module.exports.getURLBuilder = (options) => {
/**
* Builds companion targeted url
*
* @param {string} path the tail path of the url
* @param {string} subPath the tail path of the url
* @param {boolean} isExternal if the url is for the external world
* @param {boolean} [excludeHost] if the server domain and protocol should be included
*/
const buildURL = (path, isExternal, excludeHost) => {
let url = path
// supports for no path specified too
if (isExternal) {
url = `${options.server.implicitPath || ''}${url}`
const buildURL = (subPath, isExternal, excludeHost) => {
let path = ''

if (isExternal && options.server.implicitPath) {
path += options.server.implicitPath
}

if (options.server.path) {
path += options.server.path
}

url = `${options.server.path || ''}${url}`
path += subPath

if (!excludeHost) {
url = `${options.server.protocol}://${options.server.host}${url}`
if (excludeHost) {
return path
}

return url
return `${options.server.protocol}://${options.server.host}${path}`
}

return buildURL
Expand Down