The Uniform redirect file converter
The redirect file converter is a Node.js script designed to help export redirects into a file format destined for other platforms to perform the redirects.
ENV#
The recommended approach is to use a .env
file with the following properties:
Usage#
Import
This contains a function used to convert Uniform redirects to another format.
redirectEntryObject#
Convert a Uniform defined redirect into another format
Inputs
- redirect: singular redirect object
Outputs
- object representing the new format for the redirect
wildcardConverter#
Different platforms require different formats for wildcards, use this converter to adjust your wildcards. Here is an example for converting Uniform wildcards /:wildcard
-> /:wildcard
to those used by Cloudflare /*
-> /$1
.
Inputs
- sourceUrl: source URL as defined by Uniform
- sourceWildcards: array of defined wildcards, each having a
pathSegment
, the text value of wildcard andindex
where it occurs in the source URL - targetUrl: target URL as defined by Uniform
- targetWildcards: array of defined wildcards, each having a
pathSegment
, the text value of wildcard andindex
where it occurs in the target URL
Outputs
- sourceUrl: source URL with wildcards converted into a new form
- targetUrl: target URL with wildcards converted into a new form
writeFile#
Take the converted Uniform objects to be processed.
Input
- redirects: array of converted objects.