Java URL Clear cleanUrl(String encodedUrl)

Here you can find the source of cleanUrl(String encodedUrl)

Description

Clean an encoded string so it may be embedded as a query parameter.

License

Educational Community License

Parameter

Parameter Description
encodedUrl Encoded String to clean

Return

Processed URL that is safe to embed as a query parameter. It will not contain any characters that will interfere with other parameters.

Declaration

public static String cleanUrl(String encodedUrl) 

Method Source Code

//package com.java2s;
/**//  w  w w .  j  a  v a 2  s . com
 * $URL$
 * $Id$
 *
 * Copyright (c) 2010 The Sakai Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *             http://www.opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Clean an encoded string so it may be embedded as a query parameter.
     * 
     * @param encodedUrl
     *            Encoded String to clean
     * @return Processed URL that is safe to embed as a query parameter. It will
     *         not contain any characters that will interfere with other
     *         parameters.
     */
    public static String cleanUrl(String encodedUrl) {
        return encodedUrl.replaceAll("\\+", "-").replaceAll("/", "_")
                .replaceAll("=", "");
    }
}

Related

  1. cleanURL(final String input)
  2. cleanUrl(String uriStr)
  3. cleanUrl(String url)
  4. cleanUrl(String url)
  5. cleanUrlTitle(String programTitle)