• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Commonjava / indy-tracking-service / 44786446415

20 Nov 2026 05:46PM UTC coverage: 37.562% (-29.5%) from 67.036%
44786446415

push

github

rnc
Bump org.commonjava.atlas:atlas-relationships-api from 1.2.2 to 1.2.3

Bumps [org.commonjava.atlas:atlas-relationships-api](https://github.com/Commonjava/atlas) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/Commonjava/atlas/releases)
- [Commits](https://github.com/Commonjava/atlas/compare/atlas-parent-1.2.2...atlas-parent-1.2.3)

---
updated-dependencies:
- dependency-name: org.commonjava.atlas:atlas-relationships-api
  dependency-version: 1.2.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

678 of 1805 relevant lines covered (37.56%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/commonjava/indy/service/tracking/util/UrlUtils.java
1
/**
2
 * Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-tracking-service)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *         http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package org.commonjava.indy.service.tracking.util;
17

18
import java.io.ByteArrayOutputStream;
19
import java.net.MalformedURLException;
20
import java.net.URL;
21
import java.nio.charset.Charset;
22
import java.nio.charset.StandardCharsets;
23
import java.util.Map;
24

25
public final class UrlUtils
26
{
27

28
    private UrlUtils()
29
    {
30
    }
31

32
    public static String buildUrl( final String baseUrl, final String... parts ) throws MalformedURLException
33
    {
34
        return buildUrl( baseUrl, null, parts );
×
35
    }
36

37
    public static String buildUrl( final String baseUrl, final Map<String, String> params, final String... parts )
38
                    throws MalformedURLException
39
    {
40
        if ( parts == null || parts.length < 1 )
×
41
        {
42
            return baseUrl;
×
43
        }
44

45
        final StringBuilder urlBuilder = new StringBuilder();
×
46

47
        if ( parts[0] == null || !parts[0].startsWith( baseUrl ) )
×
48
        {
49
            urlBuilder.append( baseUrl );
×
50
        }
51

52
        for ( String part : parts )
×
53
        {
54
            if ( part == null || part.trim().length() < 1 )
×
55
            {
56
                continue;
×
57
            }
58
            part = part.trim();
×
59
            if ( part.startsWith( "/" ) )
×
60
            {
61
                part = part.substring( 1 );
×
62
            }
63

64
            if ( urlBuilder.length() > 0 && urlBuilder.charAt( urlBuilder.length() - 1 ) != '/' )
×
65
            {
66
                urlBuilder.append( "/" );
×
67
            }
68

69
            urlBuilder.append( part );
×
70
        }
71

72
        if ( params != null && !params.isEmpty() )
×
73
        {
74
            urlBuilder.append( "?" );
×
75
            boolean first = true;
×
76
            for ( final Map.Entry<String, String> param : params.entrySet() )
×
77
            {
78
                if ( first )
×
79
                {
80
                    first = false;
×
81
                }
82
                else
83
                {
84
                    urlBuilder.append( "&" );
×
85
                }
86

87
                urlBuilder.append( param.getKey() ).append( "=" ).append( param.getValue() );
×
88
            }
×
89
        }
90

91
        return new URL( urlBuilder.toString() ).toExternalForm();
×
92
    }
93

94
    /**
95
     * This is copied from
96
     * https://github.com/spring-projects/spring-framework/blob/581fa1419fb36d685af07554369a3fe77f4af68f/spring-core/src/main/java/org/springframework/util/StringUtils.java#L793
97
     * to handle uri segment decode problem
98
     *
99
     * @param source -
100
     * @param charset -
101
     * @return -
102
     */
103
    public static String uriDecode( String source, Charset charset )
104
    {
105
        if ( source == null || source.length() == 0 )
×
106
        {
107
            return source;
×
108
        }
109
        int length = source.length();
×
110
        Charset providedCharSet = charset;
×
111
        if ( providedCharSet == null )
×
112
        {
113
            providedCharSet = StandardCharsets.UTF_8;
×
114
        }
115

116
        ByteArrayOutputStream baos = new ByteArrayOutputStream( length );
×
117
        boolean changed = false;
×
118
        for ( int i = 0; i < length; i++ )
×
119
        {
120
            int ch = source.charAt( i );
×
121
            if ( ch == '%' )
×
122
            {
123
                if ( i + 2 < length )
×
124
                {
125
                    char hex1 = source.charAt( i + 1 );
×
126
                    char hex2 = source.charAt( i + 2 );
×
127
                    int u = Character.digit( hex1, 16 );
×
128
                    int l = Character.digit( hex2, 16 );
×
129
                    if ( u == -1 || l == -1 )
×
130
                    {
131
                        throw new IllegalArgumentException(
×
132
                                        "Invalid encoded sequence \"" + source.substring( i ) + "\"" );
×
133
                    }
134
                    baos.write( (char) ( ( u << 4 ) + l ) );
×
135
                    i += 2;
×
136
                    changed = true;
×
137
                }
×
138
                else
139
                {
140
                    throw new IllegalArgumentException( "Invalid encoded sequence \"" + source.substring( i ) + "\"" );
×
141
                }
142
            }
143
            else
144
            {
145
                baos.write( ch );
×
146
            }
147
        }
148
        return ( changed ? baos.toString( providedCharSet ) : source );
×
149
    }
150

151
    public static String uriDecode( String source )
152
    {
153
        return uriDecode( source, null );
×
154
    }
155

156
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc