[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: js/info.js (absolute_url_p): Replace with maybe_p
From: |
Per Bothner |
Subject: |
branch master updated: js/info.js (absolute_url_p): Replace with maybe_pageref_url_p. |
Date: |
Wed, 03 Mar 2021 20:08:30 -0500 |
This is an automated email from the git hooks/post-receive script.
bothner pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 5bdd011 js/info.js (absolute_url_p): Replace with maybe_pageref_url_p.
5bdd011 is described below
commit 5bdd011ddabd742da57482d54b478394d8a3948e
Author: Per Bothner <per@bothner.com>
AuthorDate: Wed Mar 3 17:07:58 2021 -0800
js/info.js (absolute_url_p): Replace with maybe_pageref_url_p.
New function checks if URL may be cross-reference to local page.
Prevents failure on links to images or stuff in sub-directories.
(config.LOCAL_HTML_PAGE_PATTERN): Patternfor HTML files.
---
ChangeLog | 7 +++++++
js/info.js | 19 ++++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f4f7210..1f90a32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-03-03 Per Bothner <per@bothner.com>
+
+ * js/info.js (absolute_url_p): Replace with maybe_pageref_url_p.
+ New function checks if URL may be cross-reference to local page.
+ Prevents failure on links to images or stuff in sub-directories.
+ (config.LOCAL_HTML_PAGE_PATTERN): Patternfor HTML files.
+
2021-03-02 Gavin Smith <gavinsmith0123@gmail.com>
* doc/texinfo.texi (Invoking pod2texi): Remove reference to
diff --git a/js/info.js b/js/info.js
index 9fc7cfc..53ccb0c 100644
--- a/js/info.js
+++ b/js/info.js
@@ -33,6 +33,7 @@
MAIN_ANCHORS: ["Top"],
WARNING_TIMEOUT: 3000,
SCREEN_MIN_WIDTH: 700,
+ LOCAL_HTML_PAGE_PATTERN: ".*[.](html|htm|xhtml)$",
SHOW_SIDEBAR_HTML: "<span>Show sidebar</span>",
HIDE_SIDEBAR_HTML: "<span>Hide sidebar</span>",
@@ -1405,7 +1406,7 @@
if (target.matches ("a"))
{
var href = link_href(target);
- if (href && !absolute_url_p (href)
+ if (href && maybe_pageref_url_p (href)
&& !external_manual_url_p (href))
{
var linkid = href_hash (href) || config.INDEX_ID;
@@ -1655,10 +1656,10 @@
var href = link_href(link);
if (!href)
continue;
- else if (absolute_url_p (href))
- link.setAttribute ("target", "_blank");
else if (external_manual_url_p (href))
link.setAttribute ("target", "_top");
+ else if (! maybe_pageref_url_p (href))
+ link.setAttribute ("target", "_blank");
else
{
var href$ = with_sidebar_query (href);
@@ -1728,16 +1729,12 @@
}
}
- /** Check if 'URL' is an absolute URL. Return true if this is the case
- otherwise return false. 'URL' must be a USVString representing a valid
- URL. */
+ /** Check if 'URL' may be a cross-reference to another page in this manual.
*/
function
- absolute_url_p (url)
+ maybe_pageref_url_p (url)
{
- if (typeof url !== "string")
- throw new TypeError ("'" + url + "' is not a string");
-
- return url.includes (":");
+ return ! (url.includes (":") || url.includes ("/"))
+ && url.match(config.LOCAL_HTML_PAGE_PATTERN);
}
/** Check if 'URL' is a link to another manual. For locally installed
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: js/info.js (absolute_url_p): Replace with maybe_pageref_url_p.,
Per Bothner <=