Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit 9eb68f3

Browse files
authored
Bugfix, webcontent url (#25)
* merge bugfixes * Expect the url also to be the title
1 parent ac9cc54 commit 9eb68f3

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ transfer = @client.create_transfer(name: "My wonderful transfer", description: "
6868
upload.add_file_at(path: '/path/to/local/file.jpg')
6969
upload.add_file_at(path: '/path/to/another/local/file.jpg')
7070
upload.add_file(name: 'README.txt', io: StringIO.new("This is the contents of the file"))
71-
upload.add_web_content(path: "https://www.the.url.you.want.to.share.com"))
71+
upload.add_web_content(url: "https://www.the.url.you.want.to.share.com"))
7272
end
7373

7474
transfer.shortened_url => "https://we.tl/SSBsb3ZlIHJ1Ynk="

lib/we_transfer_client/transfer_builder.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ def add_file_at(path:)
1616
add_file(name: File.basename(path), io: File.open(path, 'rb'))
1717
end
1818

19-
def add_web_content(path:)
20-
url = open(path, allow_redirections: :safe).base_uri.to_s
21-
url_title = url.split('/').last
22-
@items << FutureWebItem.new(url: url, title: url_title)
19+
def add_web_content(url:)
20+
@items << FutureWebItem.new(url: url, title: url)
2321
true
2422
end
2523

lib/we_transfer_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class WeTransferClient
2-
VERSION = '0.4.0'
2+
VERSION = '0.4.1'
33
end

spec/integration_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def broken.read(*)
9797
client = WeTransferClient.new(api_key: ENV.fetch('WT_API_KEY'), logger: test_logger)
9898
transfer = client.create_transfer(name: 'My collection of web content', description: 'link collection') do |builder|
9999
10.times do
100-
builder.add_web_content(path: 'https://www.wetransfer.com')
100+
builder.add_web_content(url: 'https://www.wetransfer.com')
101101
end
102102
end
103103
expect(transfer).to be_kind_of(RemoteTransfer)
@@ -135,7 +135,7 @@ def broken.read(*)
135135
expect(add_result).to eq(true)
136136

137137
# add url to transfer
138-
add_result = builder.add_web_content(path: 'http://www.wetransfer.com')
138+
add_result = builder.add_web_content(url: 'http://www.wetransfer.com')
139139
expect(add_result).to eq(true)
140140
end
141141

spec/we_transfer_client/transfer_builder_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
it 'should add a url' do
3131
transfer_builder = described_class.new
32-
transfer_builder.add_web_content(path: 'https://www.wetransfer.com')
32+
transfer_builder.add_web_content(url: 'https://www.wetransfer.com/')
3333
expect(transfer_builder.items.count).to eq(1)
3434

3535
item = transfer_builder.items.first
36-
expect(item.url).to eq('https://wetransfer.com/')
37-
expect(item.title).to eq('wetransfer.com')
36+
expect(item.url).to eq('https://www.wetransfer.com/')
37+
expect(item.title).to eq('https://www.wetransfer.com/')
3838
expect(item.local_identifier).to be_kind_of(String)
3939
end
4040
end

0 commit comments

Comments
 (0)