Skip to content

Commit ed098b8

Browse files
committed
case-insensitive pathnames for AJAX scripts
1 parent 7d5e7f1 commit ed098b8

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Perl Executing Browser
33

44
Perl Executing Browser (PEB) is a C++ [Qt 5] (https://www.qt.io/) WebKit implementation of a minimalistic HTML framework for local [Perl 5] (https://www.perl.org/) scripts executed without server as desktop data-driven applications. Perl 5 scripts can be fed directly from HTML forms using GET and POST methods or using AJAX requests. HTML interface for interaction with the built-in Perl debugger is also available.
55

6-
Inspired by [NW.js] (http://nwjs.io/) and [Electron] (http://electron.atom.io/), PEB is another reuse of web technologies for the development of desktop applications, but with Perl doing the heavy lifting.
6+
Inspired by [NW.js] (http://nwjs.io/) and [Electron] (http://electron.atom.io/), PEB is another reuse of web technologies for the development of desktop applications with Perl doing the heavy lifting.
77

88
## Design Objectives
99

@@ -74,7 +74,7 @@ Compiled and tested successfully using:
7474

7575
There is no timeout for all Perl scripts executed by PEB (AJAX and non-AJAX), but slow scripts should be optimized to avoid degradation of the user experinece.
7676

77-
There is no special naming convention for non-AJAX scripts and they are called from hyperlinks or HTML forms just like any Perl CGI script was called in the olden days of Perl CGI scripting:
77+
There is no special naming convention for non-AJAX scripts. They are called from hyperlinks or HTML forms just like any Perl CGI script was called in the olden days of Perl CGI scripting:
7878

7979
```html
8080
<form action="perl/test.pl" method="post">
@@ -91,7 +91,7 @@ Compiled and tested successfully using:
9191

9292
PEB returns all output from AJAX scripts in one piece after the script has finished with no timeout.
9393

94-
AJAX scripts must have the keyword ```ajax``` somewhere in their pathname so that PEB is able to distinguish between AJAX and non-AJAX scripts. So an AJAX script could be named ```ajax-test.pl``` or all AJAX scripts could be placed in a folder called ```ajax-scripts``` somewhere inside the application directory - see section *Settings*.
94+
AJAX scripts must have the keyword ```ajax``` (case insensitive) somewhere in their pathnames so that PEB is able to distinguish between AJAX and non-AJAX scripts. So an AJAX script could be named ```ajax-test.pl``` or all AJAX scripts could be placed in a folder called ```ajax-scripts``` somewhere inside the application directory - see section *Settings*.
9595

9696
The following example illustrates how to call a local AJAX Perl script from a local page:
9797

resources/app/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110

111111
<div id="ajax-results">
112112
<button id="ajax-button" class="btn btn-primary"
113-
data-toggle="tooltip" title="http://perl-executing-browser-pseudodomain/perl/ajax.pl"
113+
data-toggle="tooltip" title="http://perl-executing-browser-pseudodomain/perl/ajax-test.pl"
114114
data-placement="right">
115115
Local AJAX Script</button>
116116
</div>

src/peb.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,15 @@ class QAccessManager : public QNetworkAccessManager
284284
QNetworkRequest(emptyNetworkRequest));
285285
}
286286

287+
QRegExp ajaxMarker;
288+
ajaxMarker.setPattern("ajax");
289+
ajaxMarker.setCaseSensitivity(Qt::CaseInsensitive);
290+
287291
// Local AJAX GET and POST requests:
288292
if ((operation == GetOperation or
289293
operation == PostOperation) and
290294
request.url().authority() == PSEUDO_DOMAIN and
291-
request.url().path().contains("ajax")) {
295+
request.url().path().contains(ajaxMarker)) {
292296

293297
QString ajaxScriptFullFilePath = QDir::toNativeSeparators
294298
((qApp->property("application").toString())
@@ -443,7 +447,7 @@ class QAccessManager : public QNetworkAccessManager
443447
// local files and non-AJAX scripts:
444448
if (operation == GetOperation and
445449
request.url().authority() == PSEUDO_DOMAIN and
446-
(!request.url().path().contains("ajax"))) {
450+
(!request.url().path().contains(ajaxMarker))) {
447451

448452
// Get the full file path and file extension:
449453
QString fullFilePath = QDir::toNativeSeparators
@@ -539,7 +543,7 @@ class QAccessManager : public QNetworkAccessManager
539543
// POST requests to the browser pseudodomain - non-AJAX scripts:
540544
if (operation == PostOperation and
541545
request.url().authority() == PSEUDO_DOMAIN and
542-
(!request.url().path().contains("ajax"))) {
546+
(!request.url().path().contains(ajaxMarker))) {
543547

544548
if (outgoingData) {
545549
QByteArray postDataArray = outgoingData->readAll();

0 commit comments

Comments
 (0)