Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amznjp-url-normalize

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amznjp-url-normalize - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

21

lib/normalize.js
/*jslint node: true */
/*jslint nomen: true */
// Amazon.co.jp は Bot からのアクセスを規定の URL にリダイレクトする。
// その機能を利用して、URL を正規化する。
// Bot HTTP requests will be redirected by Amazon.co.jp web server.
var BOT_USERAGENT =

@@ -26,3 +25,3 @@ 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';

'use strict';
if (_.isFunction(format)) {

@@ -32,17 +31,16 @@ cb = format;

}
request.head(url, function (err, res) {
if (err) return cb(err);
// 既に正規化済みの URL にアクセスした場合、Location ヘッダが付かない
// そのため、Location ヘッダがない場合は元の URL を流用
// Location header doen't have if url is already normalized.
var location = res.headers.location || url;
var re = /dp\/(\w+)/;
var matches = location.match(re);
if (!matches) {
return cb('URL is invalid');
}
var asin = matches[1];

@@ -57,3 +55,2 @@

module.exports = normalize;
module.exports = normalize;
{
"name": "amznjp-url-normalize",
"version": "1.1.0",
"version": "1.1.1",
"description": "Normalize URL of Amazon.co.jp",

@@ -19,7 +19,7 @@ "main": "index.js",

"email": "pinemz@gmail.com",
"url": "https://github.com/pine613"
"url": "https://github.com/pine"
},
"repository": {
"type": "git",
"url": "https://github.com/pine613/amznjp-url-normalize.git"
"url": "https://github.com/pine/amznjp-url-normalize.git"
},

@@ -26,0 +26,0 @@ "license": "MIT",

amznjp-url-normalize
--------------------
[![npm version](https://badge.fury.io/js/amznjp-url-normalize.svg)](http://badge.fury.io/js/amznjp-url-normalize)
[![Build Status](https://travis-ci.org/pine613/amznjp-url-normalize.svg?branch=master)](https://travis-ci.org/pine613/amznjp-url-normalize)
[![Coverage Status](https://coveralls.io/repos/pine613/amznjp-url-normalize/badge.svg?branch=master)](https://coveralls.io/r/pine613/amznjp-url-normalize?branch=master)
[![Dependency Status](https://david-dm.org/pine613/amznjp-url-normalize.svg)](https://david-dm.org/pine613/amznjp-url-normalize)
[![devDependency Status](https://david-dm.org/pine613/amznjp-url-normalize/dev-status.svg)](https://david-dm.org/pine613/amznjp-url-normalize#info=devDependencies)
[![npm version](https://img.shields.io/npm/v/amznjp-url-normalize.svg?style=flat-square)](https://www.npmjs.com/package/amznjp-url-normalize)
[![Build Status](https://img.shields.io/travis/pine/amznjp-url-normalize/master.svg?style=flat-square)](https://travis-ci.org/pine/amznjp-url-normalize)
[![Coverage Status](https://img.shields.io/coveralls/pine/amznjp-url-normalize/master.svg?style=flat-square)](https://coveralls.io/r/pine/amznjp-url-normalize?branch=master)
[![Dependency Status](https://img.shields.io/david/pine/amznjp-url-normalize.svg?style=flat-square)](https://david-dm.org/pine/amznjp-url-normalize)
[![devDependency Status](https://img.shields.io/david/dev/pine/amznjp-url-normalize.svg?style=flat-square)](https://david-dm.org/pine/amznjp-url-normalize#info=devDependencies)
Amazon.co.jp の URL を正規化します。クロスドメイン XHR には対応していないので、ブラウザでは動作しません。
The URL normalizer of Amazon.co.jp. It works in Node.js, but any browsers not supported.
## 利用方法
## Usage

@@ -26,3 +26,3 @@ ```js

}
console.log(params.asin); // => 'B00Q5QBZCA'

@@ -33,3 +33,3 @@ console.log(params.url); // => 'http://www.amazon.co.jp/dp/B00Q5QBZCA'

## リファレンス
## References

@@ -39,3 +39,3 @@ ### normalize(url, cb)

```js
normalize("Amazon.co.jp の商品ページの URL", function (err, params) {
normalize("The URL of Amazon.co.jp", function (err, params) {
// params.asin

@@ -50,7 +50,7 @@ // params.url

var options = {
prefix: 'http://www.amazon.co.jp/dp/', // ASIN の前につける文字列
suffix: '' // ASIN の後につける文字列
prefix: 'http://www.amazon.co.jp/dp/', // A prefix of result URL
suffix: '' // A suffix of result URL
};
normalize("Amazon.co.jp の商品ページの URL", options, function (err, params) {
normalize("The URL of Amazon.co.jp", options, function (err, params) {
// params.asin

@@ -61,4 +61,3 @@ // params.url

## ライセンス
MIT License<br />
Copyright (c) 2015 Pine Mizune
## License
MIT License

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc