mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
use first ip passed though in string for ip lookup
This commit is contained in:
parent
259871cbdd
commit
e78e4d46b0
2 changed files with 10 additions and 0 deletions
|
@ -18,6 +18,11 @@ _.each EuroCountries, (country)-> currencyMappings[country] = "EUR"
|
|||
module.exports = GeoIpLookup =
|
||||
|
||||
getDetails : (ip, callback)->
|
||||
if !ip?
|
||||
e = new Error("no ip passed")
|
||||
return callback(e)
|
||||
ip = ip.trim().split(" ")[0]
|
||||
|
||||
opts =
|
||||
url: "#{settings.apis.geoIpLookup.url}/#{ip}"
|
||||
request.get opts, (err, ipDetails)->
|
||||
|
|
|
@ -49,6 +49,11 @@ describe "GeoIpLookup", ->
|
|||
assert.deepEqual returnedDetails, @stubbedResponse
|
||||
done()
|
||||
|
||||
it "should take the first ip in the string", (done)->
|
||||
@GeoIpLookup.getDetails " #{@ipAddress} 456.312.452.102 432.433.888.234", (err)=>
|
||||
@request.get.calledWith(url:@settings.apis.geoIpLookup.url+"/"+@ipAddress).should.equal true
|
||||
done()
|
||||
|
||||
describe "getCurrencyCode", ->
|
||||
|
||||
it "should return GBP for GB country", (done)->
|
||||
|
|
Loading…
Reference in a new issue