<commit_before># Connect Host Redirect

connect-redirecthost is middleware for the Express.js framework that allows redirecting multiple domains to a default one.

## Installation

    $ npm install connect-redirecthost

## Quick Start

Using connect-redirecthost is easy. Register it within Express.js as middleware by adding the following line into your app.js file before most calls to app.use(...):

```javascript
app.use(require('connect-redirecthost').redirectHost('www.example.com'));
```

Localhost is always excluded to make local development easier.

### Exceptions

Redirect exceptions are supported. If, for example, your site uses a CDN on a separate domain, you can create an exception for that domain

```javascript
app.use(require('connect-redirecthost').redirectHost({
 to: 'www.example.com',       // all requests not on www.example.com will be redirected to www.example.com
 except: 'cdn.example.com'    // except for those to cdn.example.com
}));
```

You can also specify multiple exceptions using an array.

```javascript
app.use(require('connect-redirecthost').redirectHost({
 to: 'www.example.com',
 except: ['cdn.example.com', 'origin.example.com']
}));
```

### Path handling

By default, the root-relative path is preserved during the redirect. Should the root relative path need to be modified reset,
the following options can be used, where the path will be set to the associated domain's value

```app.use(require('connect-redirecthost').redirectHost({
    to: 'www.example.com',
    changePath: {'www.example.ca': '/ca', 'www.example.us': '/us'}
}));```

You can also specify a function to determine the new path;

```app.use(require('connect-redirecthost').redirectHost({
    to: 'www.example.com',
    changePath: {
     'www.example.ca': function(host, url){return '/ca' + url;},
     'www.example.us': function(host, url){return '/us' + url;}
    }
}));```<commit_msg>Add javascript formatting directive for examples<commit_after># Connect Host Redirect

connect-redirecthost is middleware for the Express.js framework that allows redirecting multiple domains to a default one.

## Installation

    $ npm install connect-redirecthost

## Quick Start

Using connect-redirecthost is easy. Register it within Express.js as middleware by adding the following line into your app.js file before most calls to app.use(...):

```javascript
app.use(require('connect-redirecthost').redirectHost('www.example.com'));
```

Localhost is always excluded to make local development easier.

### Exceptions

Redirect exceptions are supported. If, for example, your site uses a CDN on a separate domain, you can create an exception for that domain

```javascript
app.use(require('connect-redirecthost').redirectHost({
 to: 'www.example.com',       // all requests not on www.example.com will be redirected to www.example.com
 except: 'cdn.example.com'    // except for those to cdn.example.com
}));
```

You can also specify multiple exceptions using an array.

```javascript
app.use(require('connect-redirecthost').redirectHost({
 to: 'www.example.com',
 except: ['cdn.example.com', 'origin.example.com']
}));
```

### Path handling

By default, the root-relative path is preserved during the redirect. Should the root relative path need to be modified reset,
the following options can be used, where the path will be set to the associated domain's value

```javascript
app.use(require('connect-redirecthost').redirectHost({
    to: 'www.example.com',
    changePath: {'www.example.ca': '/ca', 'www.example.us': '/us'}
}));```

You can also specify a function to determine the new path;

```javascript
app.use(require('connect-redirecthost').redirectHost({
    to: 'www.example.com',
    changePath: {
     'www.example.ca': function(host, url){return '/ca' + url;},
     'www.example.us': function(host, url){return '/us' + url;}
    }
}));```
{'fraction_non_alphanumeric': 0.12943308309603935, 'fraction_numerical': 0.0, 'mean_word_length': 4.52, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 22, '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': '7403271', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1055, 'n_words': 397}