<commit_before>/*
 Copyright (c) 2013, <NAME>. All rights reserved.
 Code licensed under the BSD License:
 https://github.com/okuryu/node-yconnect/blob/master/LICENSE
 */
"use strict";

var querystring = require("querystring"),
    OAuth2 = require("oauth").OAuth2;

var defaultRequestURL = "https://userinfo.yahooapis.jp/yconnect/v1/attribute";

function YConnect(options) {
    this.oauth = new OAuth2();
    this.token = options.token;
    this.requestURL = options.requestURL || defaultRequestURL;
}

YConnect.prototype.getUserInfo = function (params, callback) {
    if (typeof params !== "object") {
        params = {
            schema: "openid"
        };
    }
    var requestURL = this.requestURL;
    if (this.requestURL === defaultRequestURL) {
        requestURL =  + "?" + querystring.stringify(params);
    }
    if (typeof callback === "function") {
        this.oauth.get(requestURL, this.token, callback);
    }
    return this;
};

function yconnect(params) {
    var options;
    if (typeof params === "string") {
        options = {
            token: params
        };
    } else if (typeof params === "object") {
        if (typeof params.token !== "string") {
            throw new Error("the params.token (string) is required.");
        }
        options = params;
    } else {
        throw new Error("the params.token (string or object) is required.");
    }
    return new YConnect(options);
}

module.exports = yconnect;
<commit_msg>Fix handling the request URL string<commit_after>/*
 Copyright (c) 2013, <NAME>. All rights reserved.
 Code licensed under the BSD License:
 https://github.com/okuryu/node-yconnect/blob/master/LICENSE
 */
"use strict";

var querystring = require("querystring"),
    OAuth2 = require("oauth").OAuth2;

var defaultRequestURL = "https://userinfo.yahooapis.jp/yconnect/v1/attribute";

function YConnect(options) {
    this.oauth = new OAuth2();
    this.token = options.token;
    this.requestURL = options.requestURL || defaultRequestURL;
}

YConnect.prototype.getUserInfo = function (params, callback) {
    if (typeof params !== "object") {
        params = {
            schema: "openid"
        };
    }
    var requestURL = this.requestURL;
    if (this.requestURL === defaultRequestURL) {
        requestURL += "?" + querystring.stringify(params);
    }
    if (typeof callback === "function") {
        this.oauth.get(requestURL, this.token, callback);
    }
    return this;
};

function yconnect(params) {
    var options;
    if (typeof params === "string") {
        options = {
            token: params
        };
    } else if (typeof params === "object") {
        if (typeof params.token !== "string") {
            throw new Error("the params.token (string) is required.");
        }
        options = params;
    } else {
        throw new Error("the params.token (string or object) is required.");
    }
    return new YConnect(options);
}

module.exports = yconnect;

{'fraction_non_alphanumeric': 0.13704206241519673, 'fraction_numerical': 0.005427408412483039, 'mean_word_length': 2.7234848484848486, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5137861', 'n_tokens_mistral': 878, 'n_tokens_neox': 859, 'n_words': 219}