11import { getConfig } from '@edx/frontend-platform' ;
22
33export const getApiBaseUrl = ( ) => getConfig ( ) . LMS_BASE_URL ;
4+ export const getFullUrl = ( path ) => (
5+ new URL ( `${ getConfig ( ) . PUBLIC_PATH . replace ( / \/ $ / , '' ) } /${ path } ` , window . location . origin ) . href
6+ ) ;
47
58/**
69 * Enum for thread types.
@@ -137,25 +140,24 @@ export const DiscussionProvider = {
137140 OPEN_EDX : 'openedx' ,
138141} ;
139142
140- const BASE_PATH = ` ${ getConfig ( ) . PUBLIC_PATH } :courseId` ;
143+ const BASE_PATH = '/ :courseId' ;
141144
142145export const Routes = {
143146 DISCUSSIONS : {
144147 PATH : BASE_PATH ,
145148 } ,
146149 LEARNERS : {
147- PATH : `${ BASE_PATH } /learners` ,
148- POSTS : `${ BASE_PATH } /learners/:learnerUsername/posts(/:postId)?` ,
150+ PATH : `${ BASE_PATH } /learners/:learnerUsername?` ,
151+ POSTS : `${ BASE_PATH } /learners/:learnerUsername/posts/:postId?` ,
152+ POSTS_EDIT : `${ BASE_PATH } /learners/:learnerUsername/posts/:postId/edit` ,
149153 } ,
150154 POSTS : {
151155 PATH : `${ BASE_PATH } /topics/:topicId` ,
152- MY_POSTS : `${ BASE_PATH } /my-posts(/:postId)?` ,
153- ALL_POSTS : `${ BASE_PATH } /posts(/:postId)?` ,
154- NEW_POST : [
155- `${ BASE_PATH } /topics/:topicId/posts/:postId` ,
156- `${ BASE_PATH } /topics/:topicId` ,
157- `${ BASE_PATH } ` ,
158- ] ,
156+ MY_POSTS : `${ BASE_PATH } /my-posts/:postId?` ,
157+ ALL_POSTS : `${ BASE_PATH } /posts/:postId?` ,
158+ EDIT_MY_POSTS : `${ BASE_PATH } /my-posts/:postId/edit` ,
159+ EDIT_ALL_POSTS : `${ BASE_PATH } /posts/:postId/edit` ,
160+ NEW_POST : `${ BASE_PATH } /*` ,
159161 EDIT_POST : [
160162 `${ BASE_PATH } /category/:category/posts/:postId/edit` ,
161163 `${ BASE_PATH } /topics/:topicId/posts/:postId/edit` ,
@@ -166,19 +168,19 @@ export const Routes = {
166168 } ,
167169 COMMENTS : {
168170 PATH : [
169- `${ BASE_PATH } /category/:category/posts/:postId` ,
170- `${ BASE_PATH } /topics/:topicId/posts/:postId` ,
171+ `${ BASE_PATH } /category/:category/posts/:postId? ` ,
172+ `${ BASE_PATH } /topics/:topicId/posts/:postId? ` ,
171173 `${ BASE_PATH } /posts/:postId` ,
172174 `${ BASE_PATH } /my-posts/:postId` ,
173- `${ BASE_PATH } /learners/:learnerUsername/posts/:postId` ,
175+ `${ BASE_PATH } /learners/:learnerUsername/posts/:postId? ` ,
174176 ] ,
175- PAGE : `${ BASE_PATH } /:page` ,
177+ PAGE : `${ BASE_PATH } /:page/* ` ,
176178 PAGES : {
177- category : `${ BASE_PATH } /category/:category/posts/:postId` ,
178- topics : `${ BASE_PATH } /topics/:topicId/posts/:postId` ,
179+ category : `${ BASE_PATH } /category/:category/posts/:postId? ` ,
180+ topics : `${ BASE_PATH } /topics/:topicId/posts/:postId? ` ,
179181 posts : `${ BASE_PATH } /posts/:postId` ,
180182 'my-posts' : `${ BASE_PATH } /my-posts/:postId` ,
181- learners : `${ BASE_PATH } /learners/:learnerUsername/posts/:postId` ,
183+ learners : `${ BASE_PATH } /learners/:learnerUsername/posts/:postId? ` ,
182184 } ,
183185 } ,
184186 TOPICS : {
@@ -189,9 +191,10 @@ export const Routes = {
189191 ] ,
190192 ALL : `${ BASE_PATH } /topics` ,
191193 CATEGORY : `${ BASE_PATH } /category/:category` ,
192- CATEGORY_POST : `${ BASE_PATH } /category/:category/posts/:postId` ,
194+ CATEGORY_POST : `${ BASE_PATH } /category/:category/posts/:postId?` ,
195+ CATEGORY_POST_EDIT : `${ BASE_PATH } /category/:category/posts/:postId/edit` ,
193196 TOPIC : `${ BASE_PATH } /topics/:topicId` ,
194- TOPIC_POST : `${ BASE_PATH } /topics/:topicId/posts/:postId` ,
197+ TOPIC_POST : `${ BASE_PATH } /topics/:topicId/posts/:postId? ` ,
195198 TOPIC_POST_EDIT : `${ BASE_PATH } /topics/:topicId/posts/:postId/edit` ,
196199 } ,
197200} ;
@@ -205,11 +208,12 @@ export const PostsPages = {
205208} ;
206209
207210export const ALL_ROUTES = [ ]
208- . concat ( [ Routes . TOPICS . CATEGORY_POST , Routes . TOPICS . CATEGORY ] )
211+ . concat ( [ Routes . TOPICS . CATEGORY_POST , ` ${ Routes . TOPICS . CATEGORY } ?` ] )
209212 . concat ( Routes . COMMENTS . PATH )
210213 . concat ( Routes . TOPICS . PATH )
214+ . concat ( Routes . POSTS . EDIT_POST )
211215 . concat ( [ Routes . POSTS . ALL_POSTS , Routes . POSTS . MY_POSTS ] )
212216 . concat ( [ Routes . LEARNERS . POSTS , Routes . LEARNERS . PATH ] )
213- . concat ( [ Routes . DISCUSSIONS . PATH ] ) ;
217+ . concat ( [ ` ${ Routes . DISCUSSIONS . PATH } /*` ] ) ;
214218
215219export const MAX_UPLOAD_FILE_SIZE = 1024 ;
0 commit comments