File tree Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,11 @@ ConnectionConfig.prototype.serverUrlEncoding = function(str){
229229 const orgArr = str . split ( "/" )
230230 if ( orgArr . length > 3 ) {
231231 //const org = encodeURI(orgArr[3])
232+ /*
233+ * if we pass the organization name like Francesca-Bit-9e73
234+ * I need to encode it 2 times because in the database
235+ * when we create an id from a property it encodes the property value
236+ */
232237 const org = encodeURISegment ( orgArr [ 3 ] )
233238 return str . replace ( orgArr [ 3 ] , org )
234239 }
@@ -375,6 +380,8 @@ ConnectionConfig.prototype.userURL = function(user) {
375380//encodeURIComponent
376381ConnectionConfig . prototype . organizationURL = function ( orgId , action ) {
377382 let url = `${ this . apiURL ( ) } organization`
383+ //I have to encode the organization 2 times because it is saved encoded inside the database
384+ //
378385 if ( orgId ) url += `/${ encodeURISegment ( orgId ) } `
379386 if ( action ) url += `/${ encodeURISegment ( action ) } `
380387 return url
Original file line number Diff line number Diff line change @@ -1077,30 +1077,25 @@ WOQLClient.prototype.getBranches = function(dbId){
10771077//this method is not documented
10781078/*
10791079 * get the organizations and the database related
1080- * @param {string } [defaultOrg] - the organizatation to set
10811080 * @returns {Promise } A promise that returns the call response object, or an Error if rejected.
10821081 * @example
1083- * client.getUserOrganizations()
1082+ * const client = new TerminusDB.WOQLClient()
1083+ * client.getUserOrganizations().then(result=>{
1084+ * console.log(result)
1085+ * })
1086+ * //get back the datatabases for the current organization
1087+ * const organizationDatabases = client.databases()
10841088 */
1085- WOQLClient . prototype . getUserOrganizations = function ( defaultOrg ) {
1086- //this.databases(response)
1087- // return response
1089+ WOQLClient . prototype . getUserOrganizations = function ( ) {
1090+ // return response
10881091 return this . dispatch (
10891092 CONST . GET ,
10901093 this . connectionConfig . userOrganizationsURL ( ) ,
10911094 ) . then ( response => {
10921095 const orgList = Array . isArray ( response ) ? response : [ ]
10931096 this . userOrganizations ( orgList )
1094- if ( orgList . length > 0 ) {
1095- let orgObj
1096- if ( defaultOrg ) {
1097- orgObj = orgList . find ( element => element [ 'name' ] === defaultOrg )
1098- }
1099- //if I didn't find the default one I get the first result
1100- if ( ! orgObj ) {
1101- orgObj = orgList [ 0 ]
1102- }
1103- this . organization ( orgObj [ 'name' ] )
1097+ if ( orgList . length > 0 && this . connectionConfig . organization ( ) ) {
1098+ this . organization ( this . connectionConfig . organization ( ) )
11041099 }
11051100 return orgList
11061101 } )
You can’t perform that action at this time.
0 commit comments