@@ -12,6 +12,7 @@ namespace GitLink
12
12
using System . IO ;
13
13
using System . Linq ;
14
14
using System . Reflection ;
15
+ using System . Web ;
15
16
using Catel ;
16
17
using Catel . Logging ;
17
18
using GitTools ;
@@ -28,6 +29,7 @@ public static class Linker
28
29
private static readonly ILog Log = LogManager . GetCurrentClassLogger ( ) ;
29
30
30
31
private static readonly string FilenamePlaceholder = Uri . EscapeUriString ( "{filename}" ) ;
32
+ private static readonly string UrlEncodedFileNamePlaceHolder = Uri . EscapeUriString ( "{urlencoded_filename}" ) ;
31
33
private static readonly string RevisionPlaceholder = Uri . EscapeUriString ( "{revision}" ) ;
32
34
private static readonly string PdbStrExePath = Path . Combine ( Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) , "pdbstr.exe" ) ;
33
35
private static readonly string [ ] ExtensionsToIgnore = new string [ ] { ".g.cs" } ;
@@ -170,17 +172,18 @@ public static class Linker
170
172
}
171
173
172
174
string rawUrl = provider . RawGitUrl ;
173
- if ( rawUrl . Contains ( RevisionPlaceholder ) || rawUrl . Contains ( FilenamePlaceholder ) )
175
+ if ( rawUrl . Contains ( RevisionPlaceholder ) || rawUrl . Contains ( FilenamePlaceholder ) || rawUrl . Contains ( UrlEncodedFileNamePlaceHolder ) )
174
176
{
175
- if ( ! rawUrl . Contains ( RevisionPlaceholder ) || ! rawUrl . Contains ( FilenamePlaceholder ) )
177
+ if ( ! rawUrl . Contains ( RevisionPlaceholder ) || ! ( rawUrl . Contains ( FilenamePlaceholder ) || rawUrl . Contains ( UrlEncodedFileNamePlaceHolder ) ) )
176
178
{
177
179
Log . Error ( "Supplied custom URL pattern must contain both a revision and a filename placeholder." ) ;
178
180
return false ;
179
181
}
180
182
181
183
rawUrl = rawUrl
182
184
. Replace ( RevisionPlaceholder , "{0}" )
183
- . Replace ( FilenamePlaceholder , "%var2%" ) ;
185
+ . Replace ( FilenamePlaceholder , "%var2%" )
186
+ . Replace ( UrlEncodedFileNamePlaceHolder , "%var2%" ) ;
184
187
}
185
188
else
186
189
{
@@ -217,6 +220,11 @@ public static class Linker
217
220
if ( sourceFile . Value != null )
218
221
{
219
222
var relativePathForUrl = ReplaceSlashes ( provider , sourceFile . Value ) ;
223
+ if ( provider . RawGitUrl . Contains ( UrlEncodedFileNamePlaceHolder ) )
224
+ {
225
+ relativePathForUrl = HttpUtility . UrlEncode ( relativePathForUrl ) ;
226
+ }
227
+
220
228
srcSrvContext . Paths . Add ( Tuple . Create ( sourceFile . Key , relativePathForUrl ) ) ;
221
229
}
222
230
}
0 commit comments