Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
camino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
pnm-public
camino
Commits
1e2a3382
Commit
1e2a3382
authored
9 months ago
by
BITARD Michaël
Committed by
MAUBERT Vincent
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(proxy): extrait le host sans le port (
!1519
)
parent
48fcf722
No related branches found
No related tags found
1 merge request
!1519
fix(proxy): extrait le host sans le port
Pipeline
#419676
failed
9 months ago
Stage: prepare
Stage: test
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/api/src/config/index.ts
+1
-11
1 addition, 11 deletions
packages/api/src/config/index.ts
packages/common/src/strings.test.ts
+12
-1
12 additions, 1 deletion
packages/common/src/strings.test.ts
packages/common/src/strings.ts
+21
-0
21 additions, 0 deletions
packages/common/src/strings.ts
with
34 additions
and
12 deletions
packages/api/src/config/index.ts
+
1
−
11
View file @
1e2a3382
...
...
@@ -4,24 +4,14 @@ import { caminoAnneeValidator, getCurrentAnnee } from 'camino-common/src/date'
import
{
caminoConfigValidator
}
from
'
camino-common/src/static/config
'
import
{
isNullOrUndefined
}
from
'
camino-common/src/typescript-tools
'
import
{
z
}
from
'
zod
'
import
{
urlToSplit
}
from
'
camino-common/src/strings
'
if
(
process
.
env
.
VITEST
!==
'
true
'
)
{
dotenv
.
config
({
path
:
resolve
(
process
.
cwd
(),
'
../../.env
'
)
})
}
const
JWT_ALGORITHMS
=
[
'
HS256
'
,
'
HS384
'
,
'
HS512
'
,
'
RS256
'
,
'
RS384
'
,
'
RS512
'
,
'
ES256
'
,
'
ES384
'
,
'
ES512
'
,
'
PS256
'
,
'
PS384
'
,
'
PS512
'
,
'
none
'
]
as const
const
urlToSplit
=
(
url
:
undefined
|
string
):
{
value
:
string
;
host
:
string
;
port
:
number
}
|
undefined
=>
{
if
(
isNullOrUndefined
(
url
))
{
return
url
}
const
value
=
new
URL
(
url
)
return
{
value
:
url
,
host
:
value
.
host
,
port
:
parseInt
(
value
.
port
),
}
}
const
httpsProxyValidator
=
z
.
string
().
url
().
optional
().
transform
(
urlToSplit
)
const
configValidator
=
caminoConfigValidator
.
extend
({
...
...
This diff is collapsed.
Click to expand it.
packages/common/src/strings.test.ts
+
12
−
1
View file @
1e2a3382
import
{
test
,
expect
}
from
'
vitest
'
import
{
capitalize
,
levenshtein
,
slugify
}
from
'
./strings
'
import
{
capitalize
,
levenshtein
,
slugify
,
urlToSplit
}
from
'
./strings
'
test
(
'
urlToSplit
'
,
()
=>
{
expect
(
urlToSplit
(
'
http://proxy-paas.dgaln-pre1.eco4.sihc.fr:3128
'
)).
toStrictEqual
({
value
:
'
http://proxy-paas.dgaln-pre1.eco4.sihc.fr:3128
'
,
host
:
'
proxy-paas.dgaln-pre1.eco4.sihc.fr
'
,
port
:
3128
,
})
expect
(
urlToSplit
(
undefined
)).
toStrictEqual
(
undefined
)
expect
(
urlToSplit
(
'
http://google.fr
'
)).
toStrictEqual
({
value
:
'
http://google.fr
'
,
host
:
'
google.fr
'
,
port
:
80
})
expect
(
urlToSplit
(
'
https://google.fr
'
)).
toStrictEqual
({
value
:
'
https://google.fr
'
,
host
:
'
google.fr
'
,
port
:
443
})
})
test
(
'
capitalize
'
,
()
=>
{
expect
(
capitalize
(
''
)).
toBe
(
''
)
...
...
This diff is collapsed.
Click to expand it.
packages/common/src/strings.ts
+
21
−
0
View file @
1e2a3382
import
{
isNullOrUndefined
}
from
'
./typescript-tools
'
export
const
capitalize
=
<
T
extends
string
>
(
text
:
T
):
Capitalize
<
T
>
=>
{
if
(
text
.
length
>
0
)
{
return
(
text
.
substring
(
0
,
1
).
toUpperCase
()
+
text
.
substring
(
1
))
as
Capitalize
<
T
>
...
...
@@ -6,6 +8,25 @@ export const capitalize = <T extends string>(text: T): Capitalize<T> => {
return
text
as
Capitalize
<
T
>
}
export
const
urlToSplit
=
(
url
:
undefined
|
string
):
{
value
:
string
;
host
:
string
;
port
:
number
}
|
undefined
=>
{
if
(
isNullOrUndefined
(
url
))
{
return
url
}
const
value
=
new
URL
(
url
)
let
port
=
parseInt
(
value
.
port
)
if
(
isNaN
(
port
))
{
port
=
url
.
startsWith
(
'
https://
'
)
?
443
:
80
}
return
{
value
:
url
,
host
:
value
.
hostname
,
port
:
port
,
}
}
export
const
levenshtein
=
(
s
:
string
,
t
:
string
):
number
=>
{
if
(
s
===
t
)
{
return
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment