Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

save bookmark with relative path to current-site

As part of work, the same webapp is hosting at multiple location for different units

e.g.

 http://site1.come/path-to-some-page
 http://site2.come/path-to-some-page

Now I have a bookmark for site1 saved as

 http://site1.come/path-to-some-page

but for site2 I will have to again create a new bookmark. I have to deal with a new domain name each week, it is pain to do this task again and again each week.

Can I not save bookmarks relative to current host

E.g.

 http://{CURRENT_HOST}/path-to-some-page

This will save me lot of pain of saving bookmark for each new website

like image 301
harishr Avatar asked May 07 '17 08:05

harishr


People also ask

How do I change the location of my bookmarks?

At the top right, click More Bookmarks Drag a bookmark up or down, or drag a bookmark into a folder on the left. You can also copy and paste your bookmarks in the order you want.

Can I have the same bookmark in two folders?

You can copy a bookmark from a folder into another. For chrome, menu -> bookmarks -> bookmark manager, find the bookmark right click, copy, go to another folder and paste it. For firefox, click the icon on the right of the star icon and 'show all bookmarks'. The rest is the same.


2 Answers

javascript:void(window.location.href = '/path-to-some-page');

Is another way of bookmarking a relative path.

like image 54
Blakethepatton Avatar answered Oct 26 '22 21:10

Blakethepatton


I haven't seen a way to save a relative or root-relative link without resorting to a bookmarklet.

As far as a bookmarklet is concerned, it's relatively easy to generate one that will take you to whatever path you'd like:

javascript:(rel=>{location=rel.startsWith('/')?`${location.protocol}//${location.host}${rel}`:`${location.protocol}//${location.host}${location.pathname}/${rel}`})('/path')

Replace 'path' at the end with a properly escaped string containing whatever path you'd like. Note that this will differentiate between relative and root-relative paths based on whether they start with a / character.

In long form:

(rel => {
  location =
    // if the relative path starts with /
    rel.startsWith('/')
      // go to http(s)://{domain}/{relative path}
      ? `${location.protocol}//${location.host}${rel}`
      // otherwise go to http(s)://{domain}/{current path}/{relative path}
      : `${location.protocol}//${location.host}${location.pathname}/${rel}`
// call the function providing the relative path to use
})('/path')
like image 34
zzzzBov Avatar answered Oct 26 '22 21:10

zzzzBov