<commit_before>/*
 * =============================================================================
 * 
 *   Copyright (c) 2011-2014, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache 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.apache.org/licenses/LICENSE-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.
 * 
 * =============================================================================
 */
package org.thymeleaf.templateresource;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;

import org.thymeleaf.util.StringUtils;
import org.thymeleaf.util.Validate;

/**
 *
 * @author <NAME>
 * @since 3.0.0
 * 
 */
public final class UrlTemplateResource implements ITemplateResource, Serializable {


    private final URL url;
    private final String characterEncoding;



    public UrlTemplateResource(final String path, final String characterEncoding) throws MalformedURLException {

        super();

        Validate.notEmpty(path, "Resource Path cannot be null or empty");
        // Character encoding CAN be null (system default will be used)

        this.url = new URL(path);
        this.characterEncoding = characterEncoding;

    }


    public UrlTemplateResource(final URL url, final String characterEncoding) {

        super();

        Validate.notNull(url, "Resource URL cannot be null");
        // Character encoding CAN be null (system default will be used)

        this.url = url;
        this.characterEncoding = characterEncoding;

    }




    public String getDescription() {
        return this.url.toString();
    }




    public String getBaseName() {
        return TemplateResourceUtils.computeBaseName(this.url.getPath());<commit_msg>Made URLTemplateResources use a clean URL path for computing base name<commit_after>/*
 * =============================================================================
 * 
 *   Copyright (c) 2011-2014, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache 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.apache.org/licenses/LICENSE-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.
 * 
 * =============================================================================
 */
package org.thymeleaf.templateresource;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;

import org.thymeleaf.util.StringUtils;
import org.thymeleaf.util.Validate;

/**
 *
 * @author <NAME>
 * @since 3.0.0
 * 
 */
public final class UrlTemplateResource implements ITemplateResource, Serializable {


    private final URL url;
    private final String characterEncoding;



    public UrlTemplateResource(final String path, final String characterEncoding) throws MalformedURLException {

        super();

        Validate.notEmpty(path, "Resource Path cannot be null or empty");
        // Character encoding CAN be null (system default will be used)

        this.url = new URL(path);
        this.characterEncoding = characterEncoding;

    }


    public UrlTemplateResource(final URL url, final String characterEncoding) {

        super();

        Validate.notNull(url, "Resource URL cannot be null");
        // Character encoding CAN be null (system default will be used)

        this.url = url;
        this.characterEncoding = characterEncoding;

    }




    public String getDescription() {
        return this.url.toString();
    }




    public String getBaseName() {
        return TemplateResourceUtils.computeBaseName(TemplateResourceUtils.cleanPath(this.url.getPath()));
{'fraction_non_alphanumeric': 0.14317627944760358, 'fraction_numerical': 0.006092607636068237, 'mean_word_length': 3.6287593984962405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5108120', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1237, 'n_words': 425}