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

sanitize-marathon-app-id

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanitize-marathon-app-id - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

14

CHANGELOG.md

@@ -0,1 +1,15 @@

## 1.1.0 (October 16, 2015)
### Dependency Upgrades
* Update dependencies (#3)
### Enhancements
* Refactoring: avoid regexps in favor ramda (#2)
### Documentation
* Add travis and status badges (#1)
## 1.0.1 (July 27, 2015)

@@ -2,0 +16,0 @@

49

lib/sanitize.js
'use strict';
var separatorSymbol = '-',
var R = require('ramda'),
separatorSymbol = '-',
charactersToSubstitute = [ '.', '_' ],
validOutputCharacters = /[0-9a-z]/;
validOutputCharacters = new RegExp('[0-9a-z]|' + separatorSymbol),
function substituteCharacter(character) {
if (charactersToSubstitute.indexOf(character) !== -1) {
return separatorSymbol;
}
isSeparator = R.equals(separatorSymbol),
return character;
}
isSubstitutableCharacter = R.contains(R.__, charactersToSubstitute),
function isAllowedInAppId(character) {
return character === separatorSymbol || validOutputCharacters.test(character);
}
substituteCharacter = R.ifElse(isSubstitutableCharacter, R.always(separatorSymbol), R.identity),
isAllowedInAppId = R.test(validOutputCharacters),
trimExtraSeparators = R.compose(R.dropWhile(isSeparator), R.dropLastWhile(isSeparator)),
removeConsecutiveExtraSeparators = R.dropRepeatsWith(R.both(R.equals, isSeparator));
function verifiedValidName(text) {

@@ -28,16 +30,11 @@ var validMarathonId = /^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/;

module.exports = function sanitize(text) {
var moreThanOneSeparatorSymbol = new RegExp(separatorSymbol + '{2,}', 'g'),
separatorAtStartOrEnd = new RegExp('^' + separatorSymbol + '|' + separatorSymbol + '$', 'g');
return verifiedValidName(
text
.toLowerCase()
.split('')
.map(substituteCharacter)
.filter(isAllowedInAppId)
.join('')
.replace(moreThanOneSeparatorSymbol, separatorSymbol)
.replace(separatorAtStartOrEnd, '')
);
};
module.exports = R.pipe(
R.toLower,
R.split(''),
R.map(substituteCharacter),
R.filter(isAllowedInAppId),
removeConsecutiveExtraSeparators,
trimExtraSeparators,
R.join(''),
verifiedValidName
);
{
"name": "sanitize-marathon-app-id",
"version": "1.0.1",
"version": "1.1.0",
"description": "Sanitize marathon app ids.",

@@ -9,3 +9,4 @@ "scripts": {

"test:unit": "istanbul test _mocha test -- -R spec",
"changelog": "pr-log"
"changelog": "pr-log",
"coveralls": "cat ./build/coverage/lcov.info | coveralls"
},

@@ -17,10 +18,12 @@ "repository": {

"dependencies": {
"meow": "^3.3.0"
"meow": "^3.3.0",
"ramda": "^0.18.0"
},
"devDependencies": {
"chai": "3.2.0",
"eslint": "0.23.0",
"eslint-plugin-mocha": "0.4.0",
"istanbul": "0.3.17",
"mocha": "2.2.5",
"chai": "3.3.0",
"coveralls": "2.11.4",
"eslint": "1.6.0",
"eslint-plugin-mocha": "1.0.0",
"istanbul": "0.3.22",
"mocha": "2.3.3",
"pr-log": "1.3.0"

@@ -27,0 +30,0 @@ },

@@ -0,1 +1,6 @@

[![NPM Version](https://img.shields.io/npm/v/sanitize-marathon-app-id.svg?style=flat)](https://www.npmjs.org/package/sanitize-marathon-app-id)
[![Build Status](https://img.shields.io/travis/holidaycheck/sanitize-marathon-app-id/master.svg?style=flat)](https://travis-ci.org/holidaycheck/sanitize-marathon-app-id)
[![Coverage Status](https://img.shields.io/coveralls/holidaycheck/sanitize-marathon-app-id.svg?style=flat)](https://coveralls.io/r/holidaycheck/sanitize-marathon-app-id)
[![Dependencies](http://img.shields.io/david/holidaycheck/sanitize-marathon-app-id.svg?style=flat)](https://david-dm.org/holidaycheck/sanitize-marathon-app-id)
# sanitize-marathon-app-id

@@ -6,3 +11,3 @@

[Marathon](https://mesosphere.github.io/marathon) only allows a [limited character set](https://mesosphere.github.io/marathon/docs/rest-api.html#id) to be used in an app id.
If you generate these ids automatically based on e.g. current system information it is useful to sanitize the app id and filter all characters which are not allowed.
If you generate these ids automatically based on e.g. current system information it is useful to sanitize the app id and filter all characters which are not allowed.

@@ -9,0 +14,0 @@ ## Install

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