Skip to content

strawhouselabs/parse-canonical-url

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parse-canonical-url Build Status

Parse canonical url of cross device supported web sites.

What?


Many web applications redirect to a different url when browsing them from desktop or mobile devices.

This module makes it easy to parse the canonical and alternate url that almost every supported web application provides.

This module simply grabs the canonical/alternate href attribute from the html response of the given url.

Examples:
<link rel="canonical" href="https://www.linkedin.com/?trk=">
<link rel="alternate" hreflang="en-il" href="https://il.linkedin.com/">

How to use it


npm install parse-canonical-url

This module return a promise and this is how to use it:

var parseCanonicalUrl = require('parse-canonical-url');

return parseCanonicalUrl.canonical(askedUrl)
            .then(function(result) {
                console.log(result);
            })
            .catch(function(err) {
                console.log(err);
            });

OR

var parseCanonicalUrl = require('parse-canonical-url');

return parseCanonicalUrl.alternate(askedUrl)
            .then(function(result) {
                console.log(result);
            })
            .catch(function(err) {
                console.log(err);
            });
            

License

Copyright (c) 2015 Adam Gavish
Licensed under the MIT license.

About

Parse canonical url of cross device supported web sites

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%