@@ -47,35 +47,63 @@ export class ProjectRedirectView {
47
47
this . is_from_url_visible = ko . observable ( ) ;
48
48
this . is_to_url_visible = ko . observable ( ) ;
49
49
50
+ // HTML prefix content for from field, don't use user input here
51
+ this . redirect_from_prefix = ko . computed ( ( ) => {
52
+ const redirect_type = this . redirect_type ( ) ;
53
+ const lang_part = `/<span class="ui violet text">$lang</span>` ;
54
+ const version_part = `/<span class="ui violet text">$version</span>` ;
55
+
56
+ if ( redirect_type === "page" ) {
57
+ return `${ lang_part } ${ version_part } /` ;
58
+ } else if ( redirect_type === "clean_url_to_html" ) {
59
+ return `${ lang_part } ${ version_part } /<span class="ui violet text">$file</span>/` ;
60
+ } else if ( redirect_type === "clean_url_without_trailing_slash_to_html" ) {
61
+ return `${ lang_part } ${ version_part } /<span class="ui violet text">$file</span>` ;
62
+ } else if ( redirect_type === "html_to_clean_url" ) {
63
+ return `${ lang_part } ${ version_part } /<span class="ui violet text">$file</span>.html` ;
64
+ }
65
+ return "" ;
66
+ } ) ;
67
+ // User input for from field as text, no HTML allowed
50
68
this . redirect_from = ko . computed ( ( ) => {
51
- var from_url = this . from_url ( ) ;
52
- var redirect_type = this . redirect_type ( ) ;
69
+ const from_url = this . from_url ( ) ;
70
+ const redirect_type = this . redirect_type ( ) ;
53
71
if ( redirect_type === "prefix" ) {
54
72
return from_url + "faq.html" ;
55
73
} else if ( redirect_type === "page" ) {
56
- return "/$lang/$version/" + from_url . replace ( / ^ \/ + / , "" ) ;
74
+ return from_url . replace ( / ^ \/ + / , "" ) ;
57
75
} else if ( redirect_type === "exact" ) {
58
76
return from_url ;
77
+ }
78
+ return "" ;
79
+ } ) ;
80
+ // HTML prefix content for to field, don't use user input here.
81
+ this . redirect_to_prefix = ko . computed ( ( ) => {
82
+ const redirect_type = this . redirect_type ( ) ;
83
+ const lang_part = `/<span class="ui violet text">$lang</span>` ;
84
+ const version_part = `/<span class="ui violet text">$version</span>` ;
85
+
86
+ if ( redirect_type === "prefix" ) {
87
+ return `${ lang_part } ${ version_part } /faq.html` ;
88
+ } else if ( redirect_type === "page" ) {
89
+ return `${ lang_part } ${ version_part } /` ;
59
90
} else if ( redirect_type === "clean_url_to_html" ) {
60
- return "/$lang/$version/ $file/" ;
91
+ return ` ${ lang_part } ${ version_part } /<span class="ui violet text"> $file</span>.html` ;
61
92
} else if ( redirect_type === "clean_url_without_trailing_slash_to_html" ) {
62
- return "/$lang/$version/$file" ;
93
+ return `${ lang_part } ${ version_part } /<span class="ui violet text">$file</span>.html` ;
94
+ } else if ( redirect_type === "html_to_clean_url" ) {
95
+ return `${ lang_part } ${ version_part } /<span class="ui violet text">$file</span>/` ;
63
96
}
64
97
return "" ;
65
98
} ) ;
99
+ // User input for to field as text, no HTML allowed
66
100
this . redirect_to = ko . computed ( ( ) => {
67
101
const to_url = this . to_url ( ) ;
68
102
const redirect_type = this . redirect_type ( ) ;
69
- if ( redirect_type === "prefix" ) {
70
- return "/$lang/$version/faq.html" ;
71
- } else if ( redirect_type === "page" ) {
72
- return "/$lang/$version/" + to_url . replace ( / ^ \/ + / , "" ) ;
103
+ if ( redirect_type === "page" ) {
104
+ return to_url . replace ( / ^ \/ + / , "" ) ;
73
105
} else if ( redirect_type === "exact" ) {
74
106
return to_url ;
75
- } else if ( redirect_type === "clean_url_to_html" ) {
76
- return "/$lang/$version/$file.html" ;
77
- } else if ( redirect_type === "clean_url_without_trailing_slash_to_html" ) {
78
- return "/$lang/$version/$file.html" ;
79
107
}
80
108
return "" ;
81
109
} ) ;
@@ -95,6 +123,7 @@ export class ProjectRedirectView {
95
123
[
96
124
"clean_url_to_html" ,
97
125
"clean_url_without_trailing_slash_to_html" ,
126
+ "html_to_clean_url" ,
98
127
] . includes ( redirect_type )
99
128
) {
100
129
this . is_example_disabled ( false ) ;
0 commit comments