|
@@ -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
|