backbone.intercept icon indicating copy to clipboard operation
backbone.intercept copied to clipboard

Allow full URLs

Open designermonkey opened this issue 10 years ago • 3 comments

I have a situation where the app I'm working with outputs full URLs (a la http://website.com/pathname).

These URLs need to be picked up and actioned in Backbone, and I have a simple (yet horrible) solution at the moment, but I spotted this extension to Backbone, and would prefer something a little better than my poor attempt.

Anyhoo, getting to the point, would you add some code to search for and strip the first part of the url? Making the lists like so

// The following URIs will be intercepted
'path/to/my-page';
'/absolute/path/to/my-page';
'www.current-domain.com';
'http://current-domain.com';
'http://current-domain.com/absolute/path/to/my/page';

// The following URIs will be ignored by Backbone.Intercept and handled like normal
'http://www.other-domain.com';
'#my-page-fragment';
'mailto:[email protected]';
'javascript:void';

What do you think?

designermonkey avatar Jan 25 '15 18:01 designermonkey

Hey @designermonkey. If you whip up a PR / add tests, and it's not too extra code, I would consider merging it. With that said, I'm hesitant. What situation is preventing you from using relative URLs?

jamesplease avatar Jan 25 '15 18:01 jamesplease

I've always been a fan of explicit declaration in URLs, whereby I would always output the full path. I was always taught (back in the day of standards, standards, standards) that it's best practice to do this.

designermonkey avatar Jan 25 '15 19:01 designermonkey

Ah. I dislike the pattern because it binds you to a single domain name. Its also pretty uncommon practice, I think.

jamesplease avatar Jan 25 '15 19:01 jamesplease