1
1
import { getConfig } from '@edx/frontend-platform' ;
2
2
3
3
export const getApiBaseUrl = ( ) => getConfig ( ) . LMS_BASE_URL ;
4
+ export const getFullUrl = ( path ) => (
5
+ new URL ( `${ getConfig ( ) . PUBLIC_PATH . replace ( / \/ $ / , '' ) } /${ path } ` , window . location . origin ) . href
6
+ ) ;
4
7
5
8
/**
6
9
* Enum for thread types.
@@ -137,25 +140,24 @@ export const DiscussionProvider = {
137
140
OPEN_EDX : 'openedx' ,
138
141
} ;
139
142
140
- const BASE_PATH = ` ${ getConfig ( ) . PUBLIC_PATH } :courseId` ;
143
+ const BASE_PATH = '/ :courseId' ;
141
144
142
145
export const Routes = {
143
146
DISCUSSIONS : {
144
147
PATH : BASE_PATH ,
145
148
} ,
146
149
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` ,
149
153
} ,
150
154
POSTS : {
151
155
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 } /*` ,
159
161
EDIT_POST : [
160
162
`${ BASE_PATH } /category/:category/posts/:postId/edit` ,
161
163
`${ BASE_PATH } /topics/:topicId/posts/:postId/edit` ,
@@ -166,19 +168,19 @@ export const Routes = {
166
168
} ,
167
169
COMMENTS : {
168
170
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? ` ,
171
173
`${ BASE_PATH } /posts/:postId` ,
172
174
`${ BASE_PATH } /my-posts/:postId` ,
173
- `${ BASE_PATH } /learners/:learnerUsername/posts/:postId` ,
175
+ `${ BASE_PATH } /learners/:learnerUsername/posts/:postId? ` ,
174
176
] ,
175
- PAGE : `${ BASE_PATH } /:page` ,
177
+ PAGE : `${ BASE_PATH } /:page/* ` ,
176
178
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? ` ,
179
181
posts : `${ BASE_PATH } /posts/:postId` ,
180
182
'my-posts' : `${ BASE_PATH } /my-posts/:postId` ,
181
- learners : `${ BASE_PATH } /learners/:learnerUsername/posts/:postId` ,
183
+ learners : `${ BASE_PATH } /learners/:learnerUsername/posts/:postId? ` ,
182
184
} ,
183
185
} ,
184
186
TOPICS : {
@@ -189,9 +191,10 @@ export const Routes = {
189
191
] ,
190
192
ALL : `${ BASE_PATH } /topics` ,
191
193
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` ,
193
196
TOPIC : `${ BASE_PATH } /topics/:topicId` ,
194
- TOPIC_POST : `${ BASE_PATH } /topics/:topicId/posts/:postId` ,
197
+ TOPIC_POST : `${ BASE_PATH } /topics/:topicId/posts/:postId? ` ,
195
198
TOPIC_POST_EDIT : `${ BASE_PATH } /topics/:topicId/posts/:postId/edit` ,
196
199
} ,
197
200
} ;
@@ -205,11 +208,12 @@ export const PostsPages = {
205
208
} ;
206
209
207
210
export const ALL_ROUTES = [ ]
208
- . concat ( [ Routes . TOPICS . CATEGORY_POST , Routes . TOPICS . CATEGORY ] )
211
+ . concat ( [ Routes . TOPICS . CATEGORY_POST , ` ${ Routes . TOPICS . CATEGORY } ?` ] )
209
212
. concat ( Routes . COMMENTS . PATH )
210
213
. concat ( Routes . TOPICS . PATH )
214
+ . concat ( Routes . POSTS . EDIT_POST )
211
215
. concat ( [ Routes . POSTS . ALL_POSTS , Routes . POSTS . MY_POSTS ] )
212
216
. concat ( [ Routes . LEARNERS . POSTS , Routes . LEARNERS . PATH ] )
213
- . concat ( [ Routes . DISCUSSIONS . PATH ] ) ;
217
+ . concat ( [ ` ${ Routes . DISCUSSIONS . PATH } /*` ] ) ;
214
218
215
219
export const MAX_UPLOAD_FILE_SIZE = 1024 ;
0 commit comments