aymericbeaumet/metalsmith-redirect

View on GitHub
lib/create-redirections-from-arg.js

Summary

Maintainability
A
0 mins
Test Coverage
const normalize = require('./normalize');

module.exports = (redirections, options) => {
    return Object.entries(redirections).map(([source, destination]) => {
        const normalizedSource = normalize(source)
            .appendHTMLIndexIfNeeded()
            .ensureHTML(options)
            .relativeTo('/')
            .get();
        const normalizedDestination = normalize(destination)
            .relativeTo(normalizedSource)
            .get();
        return {normalizedSource, normalizedDestination};
    });
};