diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-14 02:57:45 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-14 02:58:55 +0100 |
commit | c2fbe0993228b2b62f8a916bae5271097254ce5c (patch) | |
tree | de9aba7c6c980260b30e36407c18208191371147 | |
parent | 6abe44ea0287786b5073eb63f08fce14e9688604 (diff) | |
download | chawan-c2fbe0993228b2b62f8a916bae5271097254ce5c.tar.gz |
doc: update npr redirect example
a bit more readable, and it also works with /[0-9]+ pathnames
-rw-r--r-- | doc/config.md | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/doc/config.md b/doc/config.md index db8fd560..8ecf54a4 100644 --- a/doc/config.md +++ b/doc/config.md @@ -474,7 +474,8 @@ host = '(www\.)?npr\.org' rewrite-url = ''' (x) => { x.host = "text.npr.org"; - x.pathname = x.pathname.replace(/(.*)\/.*/, "$1").replace(/.*\//, ""); + const s = x.pathname.split('/'); + x.pathname = s.at(s.length > 2 ? -2 : 1); /* No need to return; URL objects are passed by reference. */ } ''' |