From 6231dbbd26e86376171c8dc43e52d55af37f69e4 Mon Sep 17 00:00:00 2001 From: Mark Robert Henderson Date: Sun, 25 Sep 2011 01:46:39 -0500 Subject: [PATCH] Added support in node-docs for versions like -pre and -rc. Accounts for the dash. --- plugins/node/node.plugin.zsh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh index 519bc18da..b7a540397 100644 --- a/plugins/node/node.plugin.zsh +++ b/plugins/node/node.plugin.zsh @@ -1,5 +1,12 @@ # Open the node api for your current version to the optional section. # TODO: Make the section part easier to use. function node-docs { - open "http://nodejs.org/docs/$(node --version)/api/all.html#$1" + nodeversion=`node --version` + dashlocation=`echo $nodeversion | sed -n "s/-.*//p" | wc -c`; + + if [[ $dashlocation -eq 0 ]]; then + open "http://nodejs.org/docs/${nodeversion}/api/all.html#$1"; + else + open "http://nodejs.org/docs/${nodeversion:0:$dashlocation - 1}/api/all.html#$1"; + fi }