-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #865 from clintabrown/fix-routes-mount-path
Fix paths when TALK_ROOT_URL_MOUNT_PATH is set to true
- Loading branch information
Showing
5 changed files
with
26 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const {ROOT_URL, ROOT_URL_MOUNT_PATH} = require('./config'); | ||
const {URL} = require('url'); | ||
|
||
// Set the BASE_URL as the ROOT_URL, here we derive the root url by ensuring | ||
// that it ends in a `/`. | ||
const BASE_URL = ROOT_URL && ROOT_URL.length > 0 && ROOT_URL[ROOT_URL.length - 1] === '/' ? ROOT_URL : `${ROOT_URL}/`; | ||
|
||
// The BASE_PATH is simply the path component of the BASE_URL. | ||
const BASE_PATH = new URL(BASE_URL).pathname; | ||
|
||
// The MOUNT_PATH is derived from the BASE_PATH, if it is provided and enabled. | ||
// This will mount all the application routes onto it. | ||
const MOUNT_PATH = ROOT_URL_MOUNT_PATH ? BASE_PATH : '/'; | ||
|
||
module.exports = { | ||
BASE_URL: BASE_URL, | ||
BASE_PATH: BASE_PATH, | ||
MOUNT_PATH: MOUNT_PATH, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters