Skip to content

Commit

Permalink
fix(abg): do not use double slash for top-level action URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Aug 19, 2024
1 parent 96f18cc commit 9e1a50d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public val ActionCoords.repoName: String get() =
* action lives.
*/
public val ActionCoords.subName: String get() =
if (isTopLevel) "" else name.substringAfter("/")
if (isTopLevel) "" else "/${name.substringAfter("/")}"

internal fun String.toActionCoords(): ActionCoords {
val (ownerAndName, version) = this.split('@')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ internal fun ActionCoords.provideTypes(
?: Pair(emptyMap(), null)

private fun ActionCoords.actionTypesYmlUrl(gitRef: String) =
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef/$subName/action-types.yml"
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef$subName/action-types.yml"

private fun ActionCoords.actionTypesFromCatalog() =
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
"main/typings/$owner/$repoName/$version/$subName/action-types.yml"
"main/typings/$owner/$repoName/$version$subName/action-types.yml"

private fun ActionCoords.catalogMetadata() =
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
"main/typings/$owner/$repoName/metadata.yml"

private fun ActionCoords.actionTypesYamlUrl(gitRef: String) =
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef/$subName/action-types.yaml"
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef$subName/action-types.yaml"

private fun ActionCoords.fetchTypingMetadata(
metadataRevision: MetadataRevision,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class TypesProvidingTest :
// Given
val fetchUri: (URI) -> String = {
when (it) {
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yml") -> hostedByActionYml
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml") -> hostedByActionYml
else -> throw IOException()
}
}
Expand All @@ -120,7 +120,7 @@ class TypesProvidingTest :
// Given
val fetchUri: (URI) -> String = {
when (it) {
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yaml") -> hostedByActionYaml
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml") -> hostedByActionYaml
else -> throw IOException()
}
}
Expand All @@ -137,8 +137,8 @@ class TypesProvidingTest :
// Given
val fetchUri: (URI) -> String = {
when (it) {
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yml") -> hostedByActionYml
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yaml") -> hostedByActionYaml
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml") -> hostedByActionYml
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml") -> hostedByActionYaml
else -> throw IOException()
}
}
Expand All @@ -157,7 +157,7 @@ class TypesProvidingTest :
when (it) {
URI(
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
"main/typings/some-owner/some-name/v3//action-types.yml",
"main/typings/some-owner/some-name/v3/action-types.yml",
),
-> storedInTypingCatalog
else -> throw IOException()
Expand All @@ -178,12 +178,12 @@ class TypesProvidingTest :
when (it) {
URI(
"https://raw.githubusercontent.com/some-owner/some-name/" +
"some-hash//action-types.yml",
"some-hash/action-types.yml",
),
-> hostedByActionYml
URI(
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
"main/typings/some-owner/some-name/v3//action-types.yml",
"main/typings/some-owner/some-name/v3/action-types.yml",
),
-> storedInTypingCatalog
else -> throw IOException()
Expand All @@ -209,7 +209,7 @@ class TypesProvidingTest :
-> metadata
URI(
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
"main/typings/some-owner/some-name/v4//action-types.yml",
"main/typings/some-owner/some-name/v4/action-types.yml",
),
-> storedInTypingCatalogForOlderVersion
else -> throw IOException()
Expand Down

0 comments on commit 9e1a50d

Please sign in to comment.