Remove unused urlize

This commit is contained in:
Darrel O'Pry 2017-10-04 12:37:54 -04:00
parent 876cb2ca94
commit 2617621a47

View File

@ -1,4 +1,3 @@
import url from 'url';
import sanitizeFilename from 'sanitize-filename';
import { isString, escapeRegExp, flow, partialRight } from 'lodash';
@ -58,31 +57,3 @@ export function sanitizeSlug(str, { replacement = '-' } = {}) {
return normalizedSlug;
}
export function urlize(string) {
const sanitized = makePathSanitized(string);
const parsedURL = url.parse(sanitized);
return url.format(parsedURL);
}
function makePathSanitized(string) {
return makePath(string.toLowerCase());
}
function makePath(string) {
return unicodeSanitize(string).trim().replace(/[\s]/g, '-').replace(/-+/g, '-');
}
function unicodeSanitize(string) {
let target = [];
const runes = string.split('');
for (let i=0; i < string.length; i++) {
const r = runes[i];
if (r == '%' && i+2 < string.length && string.substr(i+1, 2).match(/^[0-9a-f]+$/)) {
target = target.concat([r, runes[i+1], runes[i+2]]);
} else if (r.match(/[\w .\/\\_#\+-]/u)) {
target.push(r);
}
}
return target.join('');
}