diff -r e3a19933e792 nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/util/URLEncoderHelper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nuxeo-webengine-core/src/main/java/org/nuxeo/ecm/webengine/util/URLEncoderHelper.java Mon Apr 18 18:12:42 2011 +0200 @@ -0,0 +1,36 @@ +/* + * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser General Public License + * (LGPL) version 2.1 which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl.html + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Contributors: + * eugen + */ +package org.nuxeo.ecm.webengine.util; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * @author Eugen Ionica + * + */ +public class URLEncoderHelper { + public static String encodeSegment(String segment) { + try { + segment = URLEncoder.encode(segment, "UTF-8"); + segment = segment.replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return segment; + } +}