Giter Site home page Giter Site logo

Comments (10)

MurhafSousli avatar MurhafSousli commented on May 29, 2024

Hi @PardeepJain, can you show your code?
ShareButtons checks the URL if its valid on ngAfterViewInit, if not it will use window.location.href, when you change the URL dynamically, it will not be checked but it should work with the URL as you changed it.

@Input() url: string;

ngAfterViewInit() {
  if (this.url) {
     let r = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
     if (!r.test(this.url)) {
         console.warn('ShareButtons: Invalid URL, switching to window.location.href');
         this.url = this.window ? this.window.location.href : typeof global != 'undefined' ? (<any>global).url : '';
        }
  }
  else {
     this.url = this.window ? this.window.location.href : typeof global != 'undefined' ? (<any>global).url : '';
  }
}

from ngx-sharebuttons.

PardeepJain avatar PardeepJain commented on May 29, 2024

According to you if ill not provide URL attribute than it will automatically share Current URL ?

as of now i am using like this without url like this

<share-buttons [reddit]="false" [stumbleUpOn]="false"></share-buttons>

but still not working as expected ,

i am at url http://localhost:4200/#/XYZ/191 but share url showing only http://localhost:4200/#/ why so ?

PS:- I am using hashlocationstrategy

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 29, 2024

@PardeepJain the issue is with the hashlocationstrategy, currently it will work if you disable the hash, but I will look for it once I get free time and let you know when it's fixed, thanks for letting me know.

from ngx-sharebuttons.

PardeepJain avatar PardeepJain commented on May 29, 2024

@MurhafSousli is there any time line when will you resolve this bug ? its urgent for me to use this in hashlocationstrategy

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 29, 2024

@PardeepJain Unfortunately, I'm busy atm, but if you are in a hurry you can try the following solution until I push the update,
1 - copy the package source files to your project directory
2 - import ShareButtonsModule locally (not from node_modules dir)
3 - go to share-button.component.ts and just replace window.location.href with encodeURIComponent(window.location.href) like this

ngAfterViewInit() {
    if (this.url) {
        let r = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
        if (!r.test(this.url)) {
            console.warn('ShareButtons: Invalid URL, switching to window.location.href');
            this.url = this.window ? 
                encodeURIComponent(this.window.location.href)
                : typeof global != 'undefined' ? (<any>global).url : '';
        }
    }
    else {
        this.url = this.window ? 
            encodeURIComponent(this.window.location.href) : 
            typeof global != 'undefined' ? (<any>global).url : '';
    }
.....

Hope this helps

from ngx-sharebuttons.

kuldeep89 avatar kuldeep89 commented on May 29, 2024

When i am setting Dyanmic Url to share button let suppose

https://mywebsite.com/#/abc/234

than your share button will share url only as https://mywebsite.com instead of sharing Full URL address.

PS: Binding is dynamic from Rest API.

@MurhafSousli same issue, I am using latest pakage 7.1.4 .... I have tried many thing as per documentation from last 1 day...but it is not solved
getting problem for linked in and facebook - url I am trying to share is - https://xyz.com/#/share/poster/1354 ....when sharing on linkedin and facebook....it is not sharing url ...just showing or sharing https://xyz.com

Expected Result on facebook and linkedin sharing is - share same url https://xyz.com/#/share/poster/1354
Please look into this and help me to solve this....please let me know in case of any other information you needed

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 29, 2024

@kuldeep89 Please upgrade to the latest version 8.0.0-beta.3, see the instruction in #432

from ngx-sharebuttons.

kuldeep89 avatar kuldeep89 commented on May 29, 2024

@MurhafSousli tried with beta version too...still getting same issue..

@kuldeep89 Please upgrade to the latest version 8.0.0-beta.3, see the instruction in #432

checked and tried with beta version too...still getting same issue

from ngx-sharebuttons.

prachip avatar prachip commented on May 29, 2024

Hi @MurhafSousli,

I am also trying with version 8.0.2 but still my url is not coming fully for Facebook and linkedin. For Twitter n Whatsapp working fine. I am using url as http://xyz.com/share/ADGT67S, for facebook coming as http://xyz.com

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 29, 2024

@prachip This seems to be a different issue, please use a new issue, fill the template and add a reproduction stackblitz

from ngx-sharebuttons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.