http-equiv-refresh
Advanced tools
Comparing version 0.2.0 to 0.3.0
34
index.js
"use strict"; | ||
var pattern = /^\s*(\d+)(?:\s*;(?:\s*url\s*=\s*)?(.+)?)?$/i; | ||
var pattern = /^\s*(\d+)(?:\s*;(?:\s*url\s*=)?\s*(.+)?)?$/i; | ||
@@ -8,2 +8,3 @@ | ||
{ | ||
var firstChar,lastChar,url; | ||
var result = { timeout:null, url:null }; | ||
@@ -14,4 +15,31 @@ content = pattern.exec(content); | ||
{ | ||
if (content[1] !== undefined) result.timeout = content[1] * 1; // faster than `parseInt()` | ||
if (content[2] !== undefined) result.url = content[2].trim(); | ||
if (content[1] !== undefined) | ||
{ | ||
result.timeout = ~~content[1]; // faster than `parseInt()` | ||
} | ||
if (content[2] !== undefined) | ||
{ | ||
url = content[2].trim(); | ||
firstChar = url[0]; | ||
lastChar = url[ url.length-1 ]; | ||
// Remove a single level of encapsulating quotes | ||
if (firstChar==="'" && lastChar==="'" || firstChar==='"' && lastChar==='"') | ||
{ | ||
if (url.length > 2) | ||
{ | ||
url = url.substr(1, url.length-2).trim(); | ||
} | ||
else | ||
{ | ||
url = ""; | ||
} | ||
if (url === "") url = null; | ||
} | ||
result.url = url; | ||
} | ||
} | ||
@@ -18,0 +46,0 @@ |
{ | ||
"name": "http-equiv-refresh", | ||
"description": "Parse an HTML meta refresh value.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/stevenvachon/http-equiv-refresh", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3645
37