[ https://issues.apache.org/jira/browse/DOXIATOOLS-51?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14952484#comment-14952484 ]
Marat Saitov commented on DOXIATOOLS-51: ---------------------------------------- How I see the getRelativePath( String to, String from ) in case of difference in protocol, host or port must return the "to" URL how you can see in the line 242. The bug is that it doesn't work for url's started for example with "dav:" before the protocol. For example {code} dav:https://nexus2.mysite.net:123/nexus/content/sites/site/${project.artifactId}/${project.version}/ {code} {code} 173 /** {@inheritDoc} */ 174 public Artifact getDefaultSkinArtifact( ArtifactRepository localRepository, 175 List<ArtifactRepository> remoteArtifactRepositories ) 176 throws SiteToolException 177 { 178 return getSkinArtifactFromRepository( localRepository, remoteArtifactRepositories, new DecorationModel() ); 179 } 180 181 /** {@inheritDoc} */ 182 public String getRelativePath( String to, String from ) 183 { 184 checkNotNull( "to", to ); 185 checkNotNull( "from", from ); 186 187 URL toUrl = null; 188 URL fromUrl = null; 189 190 String toPath = to; 191 String fromPath = from; 192 193 try 194 { 195 toUrl = new URL( to ); 196 } 197 catch ( MalformedURLException e ) 198 { 199 try 200 { 201 toUrl = new File( getNormalizedPath( to ) ).toURI().toURL(); 202 } 203 catch ( MalformedURLException e1 ) 204 { 205 getLogger().warn( "Unable to load a URL for '" + to + "': " + e.getMessage() ); 206 } 207 } 208 209 try 210 { 211 fromUrl = new URL( from ); 212 } 213 catch ( MalformedURLException e ) 214 { 215 try 216 { 217 fromUrl = new File( getNormalizedPath( from ) ).toURI().toURL(); 218 } 219 catch ( MalformedURLException e1 ) 220 { 221 getLogger().warn( "Unable to load a URL for '" + from + "': " + e.getMessage() ); 222 } 223 } 224 225 if ( toUrl != null && fromUrl != null ) 226 { 227 // URLs, determine if they share protocol and domain info 228 229 if ( ( toUrl.getProtocol().equalsIgnoreCase( fromUrl.getProtocol() ) ) 230 && ( toUrl.getHost().equalsIgnoreCase( fromUrl.getHost() ) ) 231 && ( toUrl.getPort() == fromUrl.getPort() ) ) 232 { 233 // shared URL domain details, use URI to determine relative path 234 235 toPath = toUrl.getFile(); 236 fromPath = fromUrl.getFile(); 237 } 238 else 239 { 240 // don't share basic URL information, no relative available 241 242 return to; 243 } 244 } 245 else if ( ( toUrl != null && fromUrl == null ) || ( toUrl == null && fromUrl != null ) ) 246 { 247 // one is a URL and the other isn't, no relative available. 248 249 return to; 250 } 251 252 // either the two locations are not URLs or if they are they 253 // share the common protocol and domain info and we are left 254 // with their URI information 255 256 String relativePath = getRelativeFilePath( fromPath, toPath ); 257 258 if ( relativePath == null ) 259 { 260 relativePath = to; 261 } 262 263 if ( getLogger().isDebugEnabled() && !relativePath.toString().equals( to ) ) 264 { 265 getLogger().debug( "Mapped url: " + to + " to relative path: " + relativePath ); 266 } 267 268 return relativePath; 269 } {code} > DefaultSiteTool.getRelativePath returns nonsense if urls do not share DNS name > ------------------------------------------------------------------------------ > > Key: DOXIATOOLS-51 > URL: https://issues.apache.org/jira/browse/DOXIATOOLS-51 > Project: Maven Doxia Tools > Issue Type: Bug > Components: Doxia Integration Tools > Affects Versions: doxia-integration-tools-1.6 > Reporter: Hervé Boutemy > > see MSITE-750 > relative path > from > {{dav:https://nexus1.mysite.net:123/nexus/content/sites/site/mysite-parent/1.0.0/}} > to > {{dav:https://nexus2.mysite.net:123/nexus/content/sites/site/mysite-child/2.0.0/}} > (notice nexus2 vs nexus1 in DNS name) > returns > {{../../../../../../../nexus2.mysite.net:123/nexus/content/sites/site/mysite-child/2.0.0}} > I don't know what's the best to do (fail?), since no relative path can be > calculated safely -- This message was sent by Atlassian JIRA (v6.3.4#6332)