public class

RepositoryUrlFragment

extends Object
java.lang.Object
   ↳ com.atlassian.stash.scm.http.RepositoryUrlFragment

Class Overview

Utility class for parsing repository slugs and project keys from scm urls.

This class works with URLs that start with:

  • <baseUrl>/scm/PROJECT_KEY/REPOSITORY_SLUG/
  • <baseUrl>/scm/PROJECT_KEY/REPOSITORY_SLUG.git/ (the .git suffix is not captured)

Summary

Public Methods
@Nullable static RepositoryUrlFragment fromPathInfo(String pathInfo)
Extracts the repository URL fragment from the given path info.
@Nonnull static RepositoryUrlFragment fromRepository(Repository repository)
@Nonnull String getProjectKey()
@Nonnull String getRepositorySlug()
@Nonnull String toPath(String basePath)
Formats this fragment as a path suitable for use with a URI, such as with URI.resolve(String), optionally prepending a provided base path.
@Nonnull String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

@Nullable public static RepositoryUrlFragment fromPathInfo (String pathInfo)

Extracts the repository URL fragment from the given path info.

Parameters
pathInfo the path info as provided by the getPathInfo() method.
Returns
  • a new repository URL fragment, or null if the path info does not contain a repository URL fragment
Throws
NullPointerException if the path info is null

@Nonnull public static RepositoryUrlFragment fromRepository (Repository repository)

Parameters
repository the repository to create a fragment for
Returns
  • a URL fragment for the specified repository

@Nonnull public String getProjectKey ()

@Nonnull public String getRepositorySlug ()

@Nonnull public String toPath (String basePath)

Formats this fragment as a path suitable for use with a URI, such as with URI.resolve(String), optionally prepending a provided base path.

Parameters
basePath the base path to prepend, or null
Returns
  • a URI-suitable path

@Nonnull public String toString ()

Returns