1 package com.bradmcevoy.http.webdav;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5
6
7
8
9
10
11
12
13
14
15 class Dest {
16
17 private static final Logger log = LoggerFactory.getLogger(Dest.class);
18
19 public final String host;
20
21
22
23
24 public final String url;
25
26
27
28
29 public final String name;
30
31
32
33 public Dest(String sourceHost, String sDest ) {
34 log.debug("sDest: " + sDest);
35 String sUrl;
36 if( sDest.endsWith("/") ) sDest = sDest.substring(0,sDest.length()-1);
37 if( sDest.contains("http://") ) {
38 String s = sDest.replace("http://","");
39 int pos = s.indexOf(":");
40 if( pos > 0 ) {
41 host = s.substring(0,pos);
42 pos = s.indexOf("/");
43 } else {
44 pos = s.indexOf("/");
45 host = s.substring(0,pos);
46 }
47 sUrl = s.substring(pos);
48 } else {
49 host = sourceHost;
50 sUrl = sDest;
51 }
52 int pos = sUrl.lastIndexOf("/");
53 if( pos <= 0 ) {
54 url = "/";
55 } else {
56 url = sUrl.substring(0,pos);
57 }
58 name = sUrl.substring(pos+1);
59 }
60 }