<p>Removes duplicate slashes.  Two or more adjacent slash ("/")
characters will be converted into one.</p>
<code>http://www.example.com/foo//bar.html
&rarr; http://www.example.com/foo/bar.html </code>
@return this instance
428499
public URLNormalizer removeDuplicateSlashes() {
        String urlRoot = HttpURL.getRoot(url);
        String path = toURL().getPath();
        String urlRootAndPath = urlRoot + path;
        String newPath = path.replaceAll("/{2,}", "/");
        String newUrlRootAndPath = urlRoot + newPath;
        url = StringUtils.replaceOnce(url, urlRootAndPath, newUrlRootAndPath);
        return this;
    }
748023
public static String sanitizeUrlPart(String theString) {
		if (theString == null) {
			return null;
		}

		boolean needsSanitization = isNeedsSanitization(theString);

		if (needsSanitization) {
			// Ok, we're sanitizing
			StringBuilder buffer = new StringBuilder(theString.length() + 10);
			for (int j = 0; j < theString.length(); j++) {

				char nextChar = theString.charAt(j);
				switch (nextChar) {
					case '"':
						buffer.append("&quot;");
						break;
					case '<':
						buffer.append("&lt;");
						break;
					default:
						buffer.append(nextChar);
						break;
				}

			} // for build escaped string

			return buffer.toString();
		}

		return theString;
	}
1126261
public CmsSite toCmsSite() {

        m_siteRoot = m_siteRoot.endsWith("/") ? m_siteRoot.substring(0, m_siteRoot.length() - 1) : m_siteRoot;
        CmsSiteMatcher matcher = CmsStringUtil.isNotEmpty(m_secureUrl) ? new CmsSiteMatcher(m_secureUrl) : null;
        CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(m_siteRoot);
        CmsUUID uuid = new CmsUUID();
        if ((site != null) && (site.getSiteMatcher() != null)) {
            uuid = (CmsUUID)site.getSiteRootUUID().clone();
        }
        String errorPage = CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_errorPage) ? m_errorPage : null;
        List<CmsSiteMatcher> aliases = new ArrayList<CmsSiteMatcher>();
        for (String alias : m_aliases) {
            CmsSiteMatcher aliasMatcher = new CmsSiteMatcher(alias);
            aliasMatcher.setRedirect(m_redirectAliases.contains(alias));
            aliases.add(aliasMatcher);
        }
        CmsSite result = new CmsSite(
            m_siteRoot,
            uuid,
            m_title,
            new CmsSiteMatcher(m_server),
            String.valueOf(m_position),
            errorPage,
            matcher,
            m_exclusiveUrl,
            m_exclusiveError,
            m_webserver,
            aliases);
        result.setParameters(m_parameters);
        try {
            result.setSSLMode(CmsSSLMode.valueOf(m_mode));
        } catch (Exception e) {
            result.setSSLMode(CmsSSLMode.NO);
            LOG.error(e.getLocalizedMessage(), e);
        }
        return result;

    }
1357338
public static String getRootRelativePath(String url) {

		Matcher matcher = URL_SEPARATOR_PATTERN.matcher(url);
		StringBuffer result = new StringBuffer();
		boolean first = true;
		while (matcher.find()) {
			if (first) {
				matcher.appendReplacement(result, "");
				first = false;
			} else {
				matcher.appendReplacement(result, ROOT_REPLACE_PATTERN);
			}
		}

		return result.toString();
	}
441037
public String create()
   {
      StringBuffer strEditor = new StringBuffer();

      strEditor.append("<div>");
      String encodedValue = HTMLEncode(value);

      if (isCompatible())
      {

         strEditor.append("<input type=\"hidden\" id=\"" + instanceName + "\" name=\"" + instanceName + "\" value=\""
            + encodedValue + "\">");

         strEditor.append(createConfigHTML());
         strEditor.append(createIFrameHTML());

      }
      else
      {
         strEditor.append("<TEXTAREA name=\"" + instanceName + "\" rows=\"4\" cols=\"40\" style=\"WIDTH: " + width
            + "; HEIGHT: " + height + "\" wrap=\"virtual\">" + encodedValue + "</TEXTAREA>");
      }
      strEditor.append("</div>");
      return strEditor.toString();
   }
621649
public String getToLink() {

        if (m_link == null) {
            String target = toString();
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(target)) {
                m_link = substituteLink(getCmsObject(), target);
            } else {
                m_link = "";
            }
        }
        return m_link;
    }
60574
private String prependSiteRoot(String url) {

        String site = getCms().getRequestContext().getSiteRoot();
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(site) || OpenCms.getSiteManager().isSharedFolder(site)) {
            site = OpenCms.getSiteManager().getDefaultUri();
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(site)
                || (OpenCms.getSiteManager().getSiteForSiteRoot(site) == null)) {
                return OpenCms.getSiteManager().getWorkplaceServer() + url;
            } else {
                return OpenCms.getSiteManager().getSiteForSiteRoot(site).getUrl() + url;
            }
        }
        return OpenCms.getSiteManager().getSiteForSiteRoot(site).getUrl() + url;
    }
621491
public boolean isHttpSuccess() {
		if (isRevisitDigest() && (getDuplicatePayload() != null)) {
			return getDuplicatePayload().isHttpSuccess();
		}
		String httpCode = getHttpCode();
		return (httpCode.startsWith("2"));
	}
683586
@RequestMapping(value = {"", "{path:^(?:(?!\\bjolokia\\b|auth|css|fonts|img|js|oauth|\\.).)*$}/**"}, produces = MediaType.TEXT_HTML_VALUE)
    public String forwardHawtioRequestToIndexHtml() {
        final String path = endpointPath.resolve("hawtio");
        final UriComponents uriComponents = ServletUriComponentsBuilder.fromPath(path)
            .path("/index.html")
            .build();
        return "forward:" + uriComponents.getPath();
    }
747744
def join_url_parts(*args):
    
    # check for edge case
    if len(args) == 1:
        return args[0]

    return_val = clean_url_segment(args[0])

    for i in range(1, len(args)):
        arg = args[i]

        if i == len(args) - 1:
            # no need to remove a trailing slash if this is the last segment
            return_val += '/' + arg
        else:
            # remove a trailing slash so it won't be duplicated
            return_val += '/' + clean_url_segment(arg)

    return return_val
595190
public URLNormalizer removeWWW() {
        String host = toURL().getHost();
        String newHost = StringUtils.removeStartIgnoreCase(host, "www.");
        url = StringUtils.replaceOnce(url, host, newHost);
        return this;
    }
312906
public final Set<String> getAsHTMLClassSet() {
		Set<String> htmlClasses = new HashSet<>();
		final String htmlClassPrefix = "wc-margin-";
		final String topClassModifier = "n-";
		final String rightClassModifier = "e-";
		final String bottomClassModifier = "s-";
		final String leftClassModifier = "w-";

		Size current = getTop();
		if (current != null) {
			htmlClasses.add(htmlClassPrefix.concat(topClassModifier).concat(current.toString()));
		}
		current = getRight();
		if (current != null) {
			htmlClasses.add(htmlClassPrefix.concat(rightClassModifier).concat(current.toString()));
		}
		current = getBottom();
		if (current != null) {
			htmlClasses.add(htmlClassPrefix.concat(bottomClassModifier).concat(current.toString()));
		}
		current = getLeft();
		if (current != null) {
			htmlClasses.add(htmlClassPrefix.concat(leftClassModifier).concat(current.toString()));
		}

		if (htmlClasses.isEmpty()) {
			return null;
		}
		return htmlClasses;
	}
816515
public static String pathOnly(String path)
   {
      String curPath = path;
      curPath = curPath.substring(curPath.indexOf("/"));
      curPath = curPath.substring(0, curPath.lastIndexOf("/"));
      if ("".equals(curPath))
      {
         curPath = "/";
      }
      return curPath;
   }
1337362
@Pure
	public static URL removeExtension(URL filename) {
		if (filename == null) {
			return null;
		}
		final String path = filename.getPath().replaceFirst(Pattern.quote(URL_PATH_SEPARATOR)
				+ "+$", ""); //$NON-NLS-1$ //$NON-NLS-2$
		int idx = path.lastIndexOf(URL_PATH_SEPARATOR);
		final StringBuilder buf = new StringBuilder((idx < 0) ? "" : //$NON-NLS-1$
				decodeHTMLEntities(path.substring(0, idx + 1)));
		final String largeBasename = decodeHTMLEntities(path.substring(idx + 1));
		idx = largeBasename.lastIndexOf(getFileExtensionCharacter());
		if (idx < 0) {
			return filename;
		}
		buf.append(largeBasename.substring(0, idx));
		try {
			if (isJarURL(filename)) {
				return new URL(
						filename.getProtocol(),
						filename.getHost(),
						filename.getPort(),
						buf.toString());
			}
			return new URI(
					filename.getProtocol(),
					filename.getUserInfo(),
					filename.getHost(),
					filename.getPort(),
					buf.toString(),
					decodeHTMLEntities(filename.getQuery()),
					filename.getRef()).toURL();
		} catch (AssertionError e) {
			throw e;
		} catch (Throwable exception) {
			//
		}
		try {
			return new URL(
					filename.getProtocol(),
					filename.getHost(),
					buf.toString());
		} catch (AssertionError e) {
			throw e;
		} catch (Throwable exception) {
			return null;
		}
	}
731349
function( string ){
            string = $this.slash.clean( string );

            if( string[ 0 ] === $this.slash.get()) string = string.substr( 1 );
            if( string[ string.length -1 ] === $this.slash.get()) string = string.substr( 0, string.length -1 );

            return string;
        }
283162
function( string ){
            if( string[ string.length -1 ] !== $this.slash.get()) string = string + $this.slash.get();

            return string;
        }
57007
public String getUrl() {
        String frontUrl = this.url;
        if (frontUrl != null && !frontUrl.isEmpty() && !frontUrl.endsWith("/")) {
            frontUrl += '/';
        }
        return frontUrl;
    }