magic string durations

This commit is contained in:
Craig Peterson 2017-06-08 09:15:14 -04:00
parent c458594788
commit 32a056e2b7
2 changed files with 60 additions and 35 deletions

View file

@ -81,13 +81,38 @@ function DEFAULTS(){
// TTL(v): Set the TTL for a DNS record.
function TTL(v) {
if (_.isString(v)){
v = stringToDuration(v);
}
return function(r) {
r.ttl = v;
}
}
function stringToDuration(v){
var matches = v.match(/^(\d+)([smhdwny]?)$/);
if (matches == null){
throw v + " is not a valid duration string"
}
unit = "s"
if (matches[2]){
unit = matches[2]
}
v = parseInt(matches[1])
var u = {"s":1, "m":60, "h":3600}
u["d"] = u.h * 24
u["w"] = u.d * 7
u["n"] = u.d * 30
u["y"] = u.d * 365
v *= u[unit];
return v
}
// DefaultTTL(v): Set the default TTL for the domain.
function DefaultTTL(v) {
if (_.isString(v)){
v = stringToDuration(v);
}
return function(d) {
d.defaultTTL = v;
}

View file

@ -190,15 +190,15 @@ var _escData = map[string]*_escFile{
"/helpers.js": {
local: "pkg/js/helpers.js",
size: 8855,
size: 8979,
modtime: 0,
compressed: `
H4sIAAAAAAAA/9wZa2/byPG7fsUcgUZkRdOPXNKCOhVVbflg1JINWb76IAjCmlxJm/CF3aUcNyf/9mIf
JJekFDtA0w/NB0fcnffMzszOWjnDwDglAbf6nc4WUQjSZAUD+NoBAKB4TRiniDIf5gtXroUJW2Y03ZIQ
JJeklNhA0w/NB0fcnffMzszOWjnDwDglAbf6nc4WUQjSZAUD+NoBAKB4TRiniDIf5gtXroUJW2Y03ZIQ
15bTGJFELnR2mlaIVyiP+JCuGQxgvuh3Oqs8CThJEyAJ4QRF5N/YdhSzGudD3L8hQVMK8b3rK+FaguwM
USb4aVqwshMUY5c/Z9iNMUeOFoeswBaLTime+ILBAKzxcHI/vLYUo538K3SneC2UEeR8kEQlii//uiCI
+/KvFlFo71Uae1nONjbFa6evPcFzmkhCLeEvEnarzWFXnBQPQwGwpQrpSm7AYDCAbvr4CQe868C7d2B3
SbYM0mSLKSNpwrpAEkXDMZwi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