Toggle navigation
Toggle navigation
This project
Loading...
Sign in
digsig
/
digsig-services
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Stefan Huber
2017-03-27 11:52:47 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
224f2a81d9917430d35008c3f5268c7b2f69866d
224f2a81
1 parent
c5383c05
new release
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
dist/services/repository.d.ts
dist/services/repository.js
dist/services/repository.d.ts
View file @
224f2a8
...
...
@@ -16,14 +16,6 @@ export declare class Repository {
tryLocalEnvironment
(
response
:
any
):
Promise
<
void
>
;
prepare
(
url
:
string
):
Promise
<
any
>
;
init
(
db_name
:
string
):
Promise
<
any
>
;
parseUrl
(
url
:
string
):
{
url
:
string
;
protocol
:
string
;
user
:
string
;
pass
:
string
;
domain
:
string
;
db_name
:
string
;
orig_db_name
:
string
;
};
parseUrl
(
url
:
string
):
any
;
prepareDocs
(
res
:
any
):
Array
<
any
>
;
}
...
...
dist/services/repository.js
View file @
224f2a8
...
...
@@ -104,7 +104,9 @@ var Repository = (function () {
_this
.
rest
.
scanEnvironment
(
response
.
local_ips
)
.
then
(
function
(
node
)
{
var
res
=
_this
.
parseUrl
(
response
.
db_url
);
resolve
(
_this
.
prepare
(
'http://'
+
node
.
ip
+
':'
+
node
.
couchPort
+
'/'
+
res
.
orig_db_name
));
var
localCouchUrl
=
'http://'
+
node
.
ip
+
':'
+
node
.
couchPort
+
'/'
+
res
.
orig_db_name
;
console
.
log
(
"prepare local couch url: "
,
localCouchUrl
);
resolve
(
_this
.
prepare
(
localCouchUrl
));
}).
catch
(
function
()
{
resolve
(
_this
.
prepare
(
response
.
db_url
));
});
...
...
@@ -115,7 +117,7 @@ var Repository = (function () {
return
new
Promise
(
function
(
resolve
,
reject
)
{
_this
.
params
=
_this
.
parseUrl
(
url
);
if
(
!
_this
.
params
)
{
reject
();
reject
(
'params are incorrect'
);
}
if
(
_this
.
db
&&
_this
.
db
.
name
==
_this
.
params
.
db_name
)
{
resolve
();
...
...
@@ -152,9 +154,10 @@ var Repository = (function () {
});
};
Repository
.
prototype
.
parseUrl
=
function
(
url
)
{
// matches: 0:user,1:password,2:domain,3:db_name
var
exp
=
/^
(
https
?)
:
\/\/(\w
+
?)
:
(\w
+
?)
@
([
a-zA-Z0-9.
\-
_:
]
+
?)\/([
a-zA-Z0-9
\-
_
]
+
?)
$/
;
var
match
=
url
.
match
(
exp
);
// matches: protocol, user, password, domain, db_name
var
expWithUsers
=
/^
(
https
?)
:
\/\/(\w
+
?)
:
(\w
+
?)
@
([
a-zA-Z0-9.
\-
_:
]
+
?)\/([
a-zA-Z0-9
\-
_
]
+
?)
$/
;
var
expWithoutUsers
=
/^
(
https
?)
:
\/\/([
a-zA-Z0-9.
\-
_:
]
+
?)\/([
a-zA-Z0-9
\-
_
]
+
?)
$/
;
var
match
=
url
.
match
(
expWithUsers
);
if
(
match
)
{
return
{
url
:
match
[
0
],
...
...
@@ -166,6 +169,16 @@ var Repository = (function () {
orig_db_name
:
match
[
5
]
};
}
match
=
url
.
match
(
expWithoutUsers
);
if
(
match
)
{
return
{
url
:
match
[
0
],
protocol
:
match
[
1
],
domain
:
match
[
2
],
db_name
:
'local_'
+
match
[
3
],
orig_db_name
:
match
[
3
]
};
}
return
null
;
};
Repository
.
prototype
.
prepareDocs
=
function
(
res
)
{
...
...
Please
register
or
login
to post a comment