Selaa lähdekoodia

2nd param is optional (will ignore urls that matches the regexp)

Former-commit-id: dc8db4ca2b99548f4da6e29c12da8918ee2f82fb
Gildas 5 vuotta sitten
vanhempi
sitoutus
5e92a7e87f
2 muutettua tiedostoa jossa 7 lisäystä ja 3 poistoa
  1. 5 1
      cli/README.MD
  2. 2 2
      cli/single-file

+ 5 - 1
cli/README.MD

@@ -66,7 +66,11 @@ SingleFile can be launched from the command line by running it into a (headless)
 
   - Save https://www.wikipedia.org and crawl its internal links with the query parameters removed from the URL
 
-  `single-file https://www.wikipedia.org --crawl-links=true --crawl-inner-links-only=true  --crawl-max-depth=1 --crawl-rewrite-rules="^(.*)\\?.*$ $1"`
+  `single-file https://www.wikipedia.org --crawl-links=true --crawl-inner-links-only=true --crawl-max-depth=1 --crawl-rewrite-rules="^(.*)\\?.*$ $1"`
+
+  - Save https://www.wikipedia.org and external links only
+
+  `single-file https://www.wikipedia.org --crawl-links=true --crawl-inner-links-only=false --crawl-external-links-max-depth=1 --crawl-rewrite-rules="^.*wikipedia.*$"`
   
 ## Troubleshooting
 

+ 2 - 2
cli/single-file

@@ -136,8 +136,8 @@ function rewriteURL(url) {
 	url = url.trim();
 	options.crawlRewriteRules.forEach(rewriteRule => {
 		const parts = rewriteRule.trim().split(/ +/);
-		if (parts.length == 2) {
-			url = url.replace(new RegExp(parts[0]), parts[1]).trim();
+		if (parts.length) {
+			url = url.replace(new RegExp(parts[0]), parts[1] || "").trim();
 		}
 	});
 	return url;