Java URI Normalize normalize(URI location)

Here you can find the source of normalize(URI location)

Description

normalize

License

Open Source License

Declaration

private static URI normalize(URI location) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 SAP AG and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from w  w  w  .jav a 2 s  .co m*/
 *    SAP AG - initial API and implementation
 *******************************************************************************/

import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    private static URI normalize(URI location) {
        // remove trailing slashes
        try {
            String path = location.getPath();
            if (path != null && path.endsWith("/")) {
                return new URI(location.getScheme(), location.getAuthority(), path.substring(0, path.length() - 1),
                        location.getQuery(), location.getFragment());
            } else {
                return location;
            }
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. normalize(final String uri)
  2. normalize(String uri, String resourceLocation, String rootLocation)
  3. normalize(URI input)
  4. normalize(URI uri)
  5. normalizedSetCookiePath(final String path, final URI originUri)
  6. normalizedUri(URI uri)
  7. normalizeGitRepoLocation(URI location)