Skip to content

Commit d6b646d

Browse files
committed
Bugfix, better trim
1 parent 6e73bb8 commit d6b646d

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

example/example.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ starwood.search({
1010
}, function(err, hotels){
1111
if (err)
1212
return console.error(err);
13-
14-
console.log(hotels);
1513
});

lib/apis.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ exports.routes = {
7878
if ($address.find('.spgCategory').length)
7979
hotel.category = utils.escape($address.find('.spgCategory').text(), 'SPG 俱乐部类别');
8080

81-
if ($address.find('.description').length)
82-
hotel.description = trim($address.find('.description').text());
81+
if ($address.find('.description').length) {
82+
if (!$address.find('.description #layerContent').length)
83+
hotel.description = trim($address.find('.description').text());
84+
}
8385
}
8486

8587
if ($(this).find('.promoSection').length) {
@@ -88,7 +90,7 @@ exports.routes = {
8890

8991
// Best rate as local currency.
9092
hotel.bestRate = $prices.find('.promos').eq(0).find('.rateAmount').length ?
91-
trim($prices.find('.promos').eq(0).find('.rateAmount').text()) : null;
93+
trim(utils.escape($prices.find('.promos').eq(0).find('.rateAmount').text(), 'CNY')) : null;
9294

9395
// Find out if cash and points could be redeemed.
9496
hotel.redeemPoints = !!$prices.find('.promos').eq(1).find('.rateAmount').length;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "DEBUG=starwood,starwood:* node_modules/.bin/mocha tests/search.js",
8-
"dev": "DEBUG=starwood,starwood:*,sdk,sdk:* node example/example.js"
8+
"dev": "DEBUG=starwood,starwood:*,sdk,sdk:* node example/example.js",
9+
"example": "npm run dev"
910
},
1011
"repository": {
1112
"type": "git",

0 commit comments

Comments
 (0)