@@ -942,7 +942,7 @@ describe('Controllers', () => {
942
942
it ( 'should redirect to account page with logged in user' , async ( ) => {
943
943
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/login` , { jar } ) ;
944
944
assert . equal ( response . statusCode , 200 ) ;
945
- assert . equal ( response . headers [ 'x-redirect' ] , '/user/foo' ) ;
945
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/user/foo' ) ) ;
946
946
assert . equal ( body , '/user/foo' ) ;
947
947
} ) ;
948
948
@@ -954,14 +954,14 @@ describe('Controllers', () => {
954
954
it ( 'should redirect to userslug' , async ( ) => {
955
955
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/uid/${ fooUid } ` ) ;
956
956
assert . equal ( response . statusCode , 200 ) ;
957
- assert . equal ( response . headers [ 'x-redirect' ] , '/user/foo' ) ;
957
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/user/foo' ) ) ;
958
958
assert . equal ( body , '/user/foo' ) ;
959
959
} ) ;
960
960
961
961
it ( 'should redirect to userslug and keep query params' , async ( ) => {
962
962
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/uid/${ fooUid } /topics?foo=bar` ) ;
963
963
assert . equal ( response . statusCode , 200 ) ;
964
- assert . equal ( response . headers [ 'x-redirect' ] , '/user/foo/topics?foo=bar' ) ;
964
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/user/foo/topics?foo=bar' ) ) ;
965
965
assert . equal ( body , '/user/foo/topics?foo=bar' ) ;
966
966
} ) ;
967
967
@@ -981,14 +981,14 @@ describe('Controllers', () => {
981
981
it ( 'api should redirect to /user/[userslug]/bookmarks' , async ( ) => {
982
982
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/me/bookmarks` , { jar } ) ;
983
983
assert . equal ( response . statusCode , 200 ) ;
984
- assert . equal ( response . headers [ 'x-redirect' ] , '/user/foo/bookmarks' ) ;
984
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/user/foo/bookmarks' ) ) ;
985
985
assert . equal ( body , '/user/foo/bookmarks' ) ;
986
986
} ) ;
987
987
988
988
it ( 'api should redirect to /user/[userslug]/edit/username' , async ( ) => {
989
989
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/me/edit/username` , { jar } ) ;
990
990
assert . equal ( response . statusCode , 200 ) ;
991
- assert . equal ( response . headers [ 'x-redirect' ] , '/user/foo/edit/username' ) ;
991
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/user/foo/edit/username' ) ) ;
992
992
assert . equal ( body , '/user/foo/edit/username' ) ;
993
993
} ) ;
994
994
@@ -1387,7 +1387,7 @@ describe('Controllers', () => {
1387
1387
it ( 'should return correct post path' , async ( ) => {
1388
1388
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/post/${ pid } ` ) ;
1389
1389
assert . equal ( response . statusCode , 200 ) ;
1390
- assert . equal ( response . headers [ 'x-redirect' ] , '/topic/1/test-topic-title' ) ;
1390
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/topic/1/test-topic-title' ) ) ;
1391
1391
assert . equal ( body , '/topic/1/test-topic-title' ) ;
1392
1392
} ) ;
1393
1393
} ) ;
@@ -1500,7 +1500,7 @@ describe('Controllers', () => {
1500
1500
} ) ;
1501
1501
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/users` ) ;
1502
1502
assert . equal ( response . statusCode , 200 ) ;
1503
- assert . equal ( response . headers [ 'x-redirect' ] , '/api/popular' ) ;
1503
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/api/popular' ) ) ;
1504
1504
assert ( body , '/api/popular' ) ;
1505
1505
} ) ;
1506
1506
@@ -1605,12 +1605,12 @@ describe('Controllers', () => {
1605
1605
const { cid } = category ;
1606
1606
1607
1607
let result = await request . get ( `${ nconf . get ( 'url' ) } /api/category/${ category . slug } ` , { jar } ) ;
1608
- assert . equal ( result . response . headers [ 'x-redirect' ] , 'https://nodebb.org' ) ;
1608
+ assert . equal ( result . response . headers [ 'x-redirect' ] , encodeURIComponent ( 'https://nodebb.org' ) ) ;
1609
1609
assert . equal ( result . body , 'https://nodebb.org' ) ;
1610
1610
await categories . setCategoryField ( cid , 'link' , '/recent' ) ;
1611
1611
1612
1612
result = await request . get ( `${ nconf . get ( 'url' ) } /api/category/${ category . slug } ` , { jar } ) ;
1613
- assert . equal ( result . response . headers [ 'x-redirect' ] , '/recent' ) ;
1613
+ assert . equal ( result . response . headers [ 'x-redirect' ] , encodeURIComponent ( '/recent' ) ) ;
1614
1614
assert . equal ( result . body , '/recent' ) ;
1615
1615
} ) ;
1616
1616
@@ -1686,7 +1686,7 @@ describe('Controllers', () => {
1686
1686
it ( 'should redirect if page is out of bounds' , async ( ) => {
1687
1687
const { response, body } = await request . get ( `${ nconf . get ( 'url' ) } /api/unread?page=-1` , { jar } ) ;
1688
1688
assert . equal ( response . statusCode , 200 ) ;
1689
- assert . equal ( response . headers [ 'x-redirect' ] , '/unread?page=1' ) ;
1689
+ assert . equal ( response . headers [ 'x-redirect' ] , encodeURIComponent ( '/unread?page=1' ) ) ;
1690
1690
assert . equal ( body , '/unread?page=1' ) ;
1691
1691
} ) ;
1692
1692
} ) ;
0 commit comments