web-security
Advanced tools
Comparing version 0.0.3 to 0.0.4
20
index.js
@@ -9,3 +9,3 @@ /** | ||
* @date 13/08/2016 | ||
* @version 0.0.3 (beta) | ||
* @version 0.0.4 (beta) | ||
*/ | ||
@@ -139,3 +139,3 @@ | ||
var searchLocation = location.search; | ||
var unSafeChar = searchLocation.match(/[script]/g); | ||
var unSafeChar = searchLocation.match(/[script|document|cookie]/g); | ||
@@ -151,2 +151,18 @@ ((unSafeChar !== null) ? (unSafeChar.length > 0 ? location.replace("/") : "") : ""); | ||
webSecurity.safeUrlWithHash = function(hash) | ||
{ | ||
if(typeof window !== 'undefined') | ||
{ | ||
var searchLocation = location.search; | ||
var unSafeChar = searchLocation.match(/[script|document|cookie]/g); | ||
((unSafeChar !== null) ? (unSafeChar.length > 0 ? location.replace(hash) : "") : ""); | ||
} | ||
else | ||
{ | ||
throw "Node Doesn't Support safeUrl"; | ||
} | ||
}; | ||
webSecurity.unSafeUrl = function() | ||
@@ -153,0 +169,0 @@ { |
@@ -91,3 +91,3 @@ { | ||
}, | ||
"version": "0.0.3" | ||
"version": "0.0.4" | ||
} |
@@ -13,3 +13,3 @@ ## Web-Security | ||
@date: 14/08/2016 | ||
@version: 0.0.3 (beta) | ||
@version: 0.0.4 (beta) | ||
@@ -54,2 +54,5 @@ ## Description: | ||
- unSafeUrl() {}; | ||
- @param: link after base url eg. /home | ||
unSafeUrl(param) {}; | ||
@@ -138,4 +141,4 @@ | ||
```js | ||
var url = "http://randomrise.com/?<script> document.cookie </script>"; | ||
xs.safeUrl(url); | ||
var browserURL = "http://randomrise.com/?<script> document.cookie </script>"; | ||
xs.safeUrl(); | ||
@@ -148,6 +151,15 @@ // it will reload/refresh the page without search parameter. | ||
```js | ||
var url = "http://randomrise.com/?<script> document.cookie </script>"; | ||
xs.unSafeUrl(url); | ||
var browserURL = "http://randomrise.com/?<script> document.cookie </script>"; | ||
xs.unSafeUrl(); | ||
// it will reload/refresh the page with search parameter. | ||
``` | ||
``` | ||
### safeUrlWithHash | ||
```js | ||
var browserURL = "http://randomrise.com/?<script> document.cookie </script>"; | ||
xs.unSafeUrl('/home'); // eg. you can keep what ever you want. | ||
// it will reload/refresh the page with /home after the default url. | ||
``` |
10584
162
162