Skip to content

Commit

Permalink
Merge pull request #7 from hostari/thundrestore-client-base-url
Browse files Browse the repository at this point in the history
Use new base url for thunderstore client
  • Loading branch information
Weltinio authored Apr 15, 2024
2 parents a3e5bfa + fe506b7 commit eb8618d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/thunderstore/methods/package_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe Thunderstore::Package do
context "valheim" do
describe ".list_packages" do
it "retrieves all packages" do
WebMock.stub(:get, "https://valheim.thunderstore.io/api/v1/package/")
WebMock.stub(:get, "https://thunderstore.io/api/v1/package/")
.to_return(status: 200, body: File.read("spec/support/All_Packages-1650682645115.json"), headers: {"Content-Type" => "application/json"})

client = Thunderstore::Client.new("valheim")
Expand Down
6 changes: 4 additions & 2 deletions src/thunderstore/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Thunderstore
class Client
property community = ""

BASE_URL = "https://thunderstore.io"

def initialize(@community : String = "")
end

Expand All @@ -14,9 +16,9 @@ module Thunderstore

# Returns the base url for which this client will make API requests to.
def base_url : URI
return URI.parse("https://thunderstore.io") if community.empty?
return URI.parse(BASE_URL) if community.empty?

URI.parse("https://#{community}.thunderstore.io")
URI.parse("#{BASE_URL}/c/#{community}")
end

# Initializes an `HTTP::Client` for the configured `base_url`, and executes a GET request on the specified `path`.
Expand Down

0 comments on commit eb8618d

Please sign in to comment.