<commit_before>'use strict';

// MODULES //

var debug = require( 'debug' )( 'licenses:pkg:repo' );
var prefix = require( './stdlib.js' );
var isObject = require( prefix+'@stdlib/utils/is-object' ); // TODO: plain object
var replace = require( prefix+'@stdlib/string/replace' );


// REPO //

/**
* Extracts a repository URL (if available) from `package.json` data.
*
* @private
* @param {Object} pkg - `package.json` data
* @returns {(string|null)} repo URL or null
*/
function repo( pkg ) {
	var url;
	if ( isObject( pkg.repository ) ) {
		url = pkg.repository.url;
		if ( url ) {
			// GitHub URLs:
			url = replace( url, 'git\\+ssh\\:\\/\\/git\\@', 'git://' );
			url = replace( url, 'git\\+', '' );
			url = replace( url, 'git\\:\\/\\/', 'https://' );
			url = replace( url, 'git\\@', 'https://' );
			url = replace( url, '\\.git', '' );<commit_msg>Use utility to test if a value is a plain object<commit_after>'use strict';

// MODULES //

var debug = require( 'debug' )( 'licenses:pkg:repo' );
var prefix = require( './stdlib.js' );
var isObject = require( prefix+'@stdlib/utils/is-plain-object' );
var replace = require( prefix+'@stdlib/string/replace' );


// REPO //

/**
* Extracts a repository URL (if available) from `package.json` data.
*
* @private
* @param {Object} pkg - `package.json` data
* @returns {(string|null)} repo URL or null
*/
function repo( pkg ) {
	var url;
	if ( isObject( pkg.repository ) ) {
		url = pkg.repository.url;
		if ( url ) {
			// GitHub URLs:
			url = replace( url, 'git\\+ssh\\:\\/\\/git\\@', 'git://' );
			url = replace( url, 'git\\+', '' );
			url = replace( url, 'git\\:\\/\\/', 'https://' );
			url = replace( url, 'git\\@', 'https://' );
			url = replace( url, '\\.git', '' );
{'fraction_non_alphanumeric': 0.23161551823972207, 'fraction_numerical': 0.0, 'mean_word_length': 2.9272727272727272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7575619', 'n_tokens_mistral': 660, 'n_tokens_neox': 611, 'n_words': 171}