This repository was archived by the owner on Jun 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-7
lines changed Expand file tree Collapse file tree 4 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 1
1
build
2
2
node_modules
3
- package-lock.json
3
+ package-lock.json
Original file line number Diff line number Diff line change @@ -46,19 +46,25 @@ Per facilitare la scrittura delle regex di riconoscimento sono disponibili gli _
46
46
### simpleHelper
47
47
Riconosce semplici path identificati da una stringa iniziale statica.
48
48
49
- Il _builder_ accetta un parametro :
49
+ Il _builder_ accetta due parametri :
50
50
- _base_: stringa iniziale dell' URI
51
+ - _usePath_ : indica alla regex se riconoscere come gruppo la stringa che segue _base_
51
52
52
53
La regex crea un gruppo:
53
54
54
- - 1: (opzionale) contiene il path
55
+ - 1: (opzionale) contiene il path se _usePath_ è _true_
55
56
56
- Ad esempio invocando l' helper `simpleHelper("manuale-servizi/manuale-servizi-v1.0 ")` otteniamo una regex che restituirà i seguenti valori:
57
+ Ad esempio invocando l' helper `simpleHelper("/path_molto_esteso/sotto-path/path_finale ")` otteniamo una regex che restituirà i seguenti valori:
57
58
58
59
| URI | gruppo 1 |
59
60
| --- | ------- |
60
- | /manuale-servizi/manuale-servizi-v1.0/changelog | /changelog
61
+ | /path_molto_esteso/sotto_path/path_finale | /path_finale
62
+
63
+ Mentre se invochiamo lo stesso helper `simpleHelper("/path_molto_esteso/sotto-path/path_finale", false)` otteniamo
61
64
65
+ | URI | gruppo 1 |
66
+ | --- | ------- |
67
+ | /path_molto_esteso/sotto_path/path_finale | _null_
62
68
63
69
### versionedHelper
64
70
Riconosce path in cui sono presenti informazioni di versione, come ad es. in `/saci/saci-1.2.3`.
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ describe('IO rules', () => {
112
112
it ( 'Should intercept io-guida-tecnica resources that must be redirected' , ( ) => {
113
113
expect ( handler ( buildRequest ( "/io-guida-tecnica" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides/io-guida-tecnica" ) ) ;
114
114
expect ( handler ( buildRequest ( "/io-guida-tecnica/changelog" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides/io-guida-tecnica/changelog" ) ) ;
115
+ expect ( handler ( buildRequest ( "/io-guida-tecnica/v5.2-preview" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides" ) ) ;
116
+ expect ( handler ( buildRequest ( "/io-guida-tecnica/v5.2-preview/changelog" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides" ) ) ;
115
117
expect ( handler ( buildRequest ( "/io-guida-tecnica/v5.0" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides/io-guida-tecnica/v5.0" ) ) ;
116
118
expect ( handler ( buildRequest ( "/io-guida-tecnica/v5.0/changelog" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides/io-guida-tecnica/v5.0/changelog" ) ) ;
117
119
expect ( handler ( buildRequest ( "/io-guida-tecnica/v2.4/changelog" ) ) ) . toEqual ( buildResponse ( "https://developer.pagopa.it/app-io/guides/io-guida-tecnica/v2.4/changelog" ) ) ;
Original file line number Diff line number Diff line change @@ -9,8 +9,12 @@ var stringToRegex = function(strToRegex) {
9
9
return strToRegex . replaceAll ( "/" , "\\/" ) . replaceAll ( "." , "\\." )
10
10
}
11
11
12
- var simpleHelper = function ( base ) {
13
- var stringRegex = stringToRegex ( base ) + "(.*)" ;
12
+ var simpleHelper = function ( base , usePath ) {
13
+ var stringRegex = stringToRegex ( base ) ;
14
+ if ( usePath === undefined ) {
15
+ stringRegex += "(.*)" ;
16
+ }
17
+
14
18
var regex = new RegExp ( stringRegex ) ;
15
19
regex . _helper = "simpleHelper" ;
16
20
return regex ;
@@ -28,6 +32,9 @@ var versionedHelper = function(base, versionPrefix) {
28
32
} ;
29
33
30
34
var regexPatterns = [
35
+ {
36
+ regex : simpleHelper ( "/io-guida-tecnica/v5.2-preview" , false ) , redirectTo : "/app-io/guides"
37
+ } ,
31
38
{
32
39
regex : versionedHelper ( "/io-guida-tecnica/io-guida-tecnica-2.3" ) , redirectTo : "/app-io/guides/io-guida-tecnica/v2.3"
33
40
} ,
You can’t perform that action at this time.
0 commit comments