Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
83 views
in Technique[技术] by (71.8m points)

node.js - Hot to get URL every change the page

I try to create plugin ini hapi.js framework, I register my plugin and try to get URL every time user change the page. Example: I open http://example.com will get http://example.com or http://example.com/about will get http://example.com/about.

This is my code I have try. Plugin:

exports.plugin = {
    name: 'dlAcl',
    pkg: require(__basedir + '/package.json'),
    register: async (server, options, next) => {
        server.ext('onPostAuth', (request, replay) => {
            console.log('### ' + request.url);
            return replay.continue;
        });
    },
};

With this code I got the URL but not only the URL address, all request like .css and .js request show too like this.

http://example.com/
http://example.com/bootstrap/dist/css/bootstrap.min.css
http://example.com/datatables.net-bs4/css/dataTables.bootstrap4.min.css
http://example.com/multiselect/css/multi-select.css
http://example.com/tinymce/tinymce.min.js
http://example.com/scripts/global.js

How if I just want get http://example.com/?

Thanks for advance.

question from:https://stackoverflow.com/questions/65858192/hot-to-get-url-every-change-the-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...